commit | author | age
|
81705d
|
1 |
#!/bin/sh |
JG |
2 |
|
|
3 |
if [ $EUID != 0 ]; then |
|
4 |
sudo "$0" "$@" |
|
5 |
exit $? |
|
6 |
fi |
|
7 |
|
|
8 |
export BORG_REPO=/backup/borg |
|
9 |
|
|
10 |
# add --list to view files as they're added to the backup |
|
11 |
borg create \ |
|
12 |
--verbose \ |
|
13 |
--stats \ |
|
14 |
--compression zstd,22 \ |
|
15 |
--one-file-system \ |
|
16 |
--exclude-caches \ |
|
17 |
--exclude /var/cache \ |
f53d32
|
18 |
--exclude /backup \ |
81705d
|
19 |
\ |
JG |
20 |
::"$(date +%F)" \ |
|
21 |
/ |
|
22 |
|
|
23 |
BACKUP_EXIT=$? |
|
24 |
|
|
25 |
borg prune \ |
|
26 |
--list \ |
|
27 |
--keep-daily 7 \ |
|
28 |
--keep-monthly 2 |
|
29 |
|
|
30 |
PRUNE_EXIT=$? |
|
31 |
|
|
32 |
GLOBAL_EXIT=$(( BACKUP_EXIT > PRUNE_EXIT ? BACKUP_EXIT : PRUNE_EXIT )) |
|
33 |
|
|
34 |
if [ $GLOBAL_EXIT -eq 0 ]; then |
|
35 |
echo "Backup and Prune finished with successfully" |
|
36 |
elif [ $GLOBAL_EXIT -eq 1 ]; then |
|
37 |
echo "Backup and/or Prune finshed with warnings" |
|
38 |
else |
|
39 |
echo "Backup and/or Prune finished with errors" |
|
40 |
fi |
|
41 |
|
|
42 |
exit $GLOBAL_EXIT |