-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathborg_prune
More file actions
executable file
·61 lines (48 loc) · 1.44 KB
/
Copy pathborg_prune
File metadata and controls
executable file
·61 lines (48 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
if [ $# -ne 1 ] || ([ "$1" != "-l" ] && [ "$1" != "-q" ] && [ "$1" != "-u" ])
then
echo "First parameter should be -l for long(on server) or -q for quick(on /stockage/ or -u for USB (on /mnt/dd))"
exit 1
fi
if [ "$(whoami)" != "root" ]
then
echo "Please run as root"
exit 2
fi
if [ "$1" == "-l" ]
then
export BORG_SERVER_REPO="ssh://dionisos@192.168.1.48:22/home/dionisos/save_portable"
fi
if [ "$1" == "-q" ]
then
export BORG_SERVER_REPO="/stockage/borg_save"
directory="stockage"
fi
if [ "$1" == "-u" ]
then
export BORG_SERVER_REPO="/mnt/dd/save_pc_fixe"
directory="dd"
fi
echo "-----------start DRY-RUN-----------"
borg prune --dry-run -v --list --keep-yearly="-1" --keep-monthly=5 --keep-last=5 "$BORG_SERVER_REPO"
echo "-----------end DRY-RUN-----------"
echo "Do it ? (yes→yes, other→no)"
start=$(df -h | grep "$directory" | tr -s ' ' | cut -d ' ' -f 4)
read proceed
if [ "$proceed" == "yes" ]
then
echo "PRUNE"
borg prune -v --list --keep-yearly="-1" --keep-monthly=5 --keep-last=5 "$BORG_SERVER_REPO"
echo "COMPACT"
borg compact --progress "$BORG_SERVER_REPO"
fi
end=$(df -h | grep "$directory" | tr -s ' ' | cut -d ' ' -f 4)
echo "-----------------------------------"
if [ "$directory" == "stockage" ]
then
echo "Memory available in directory '/stockage' ('/dev/sda5')"
else
echo "Memory available in directory '/mnt/dd' ('/dev/sdb1')"
fi
echo "At the start : $start"
echo "At the end : $end"