injection de la sauvegarde s...
|
1 |
#!/bin/bash |
2 | ||
version récente du script de...
|
3 |
cat > /dev/shm/rotate_inject << EOC |
4 |
/var/log/${0##*/} { |
|
5 |
rotate 31 |
|
6 |
compress |
|
7 |
missingok |
|
8 |
} |
|
9 |
EOC |
|
10 |
logrotate -fs /dev/shm/rotate_inject.state /dev/shm/rotate_inject |
|
11 |
rm -f /dev/shm/rotate_inject /dev/shm/rotate_inject.state |
|
injection de la sauvegarde s...
|
12 | |
version récente du script de...
|
13 |
set -e |
injection de la sauvegarde s...
|
14 | |
version récente du script de...
|
15 |
mountpoint=${1:-/media/backup} |
16 |
backupdir=$mountpoint/backup |
|
17 |
archives=$mountpoint/archives |
|
18 |
incremental=30 |
|
injection de la sauvegarde s...
|
19 | |
20 |
PATH=/usr/sbin:/usr/bin:/sbin:/bin |
|
21 | ||
version récente du script de...
|
22 |
test -d $mountpoint/ |
23 |
grep -qw $mountpoint /proc/mounts |
|
injection de la sauvegarde s...
|
24 | |
version récente du script de...
|
25 |
test -d $archives || mkdir -p $archives |
injection de la sauvegarde s...
|
26 | |
version récente du script de...
|
27 |
for i in $(seq $incremental -1 1); do |
28 |
if test -e $archives/${backupdir##*/}.$i; then |
|
29 |
mv $archives/${backupdir##*/}.$i $archives/${backupdir##*/}.$((i+1)) |
|
injection de la sauvegarde s...
|
30 |
fi |
version récente du script de...
|
31 |
done |
injection de la sauvegarde s...
|
32 | |
version récente du script de...
|
33 |
rsync_opt=('-rlvzx' '--times' '--delete' '--omit-link-times') |
34 |
if test -d $backupdir; then |
|
35 |
mv $backupdir $archives/${backupdir##*/}.1 |
|
36 |
# if test $(date +%u) -ne 1; then # real copy every monday |
|
37 |
rsync_opt+=("--link-dest=$archives/${backupdir##*/}.1") |
|
38 |
# fi |
|
injection de la sauvegarde s...
|
39 |
fi |
40 | ||
version récente du script de...
|
41 |
rm -fr $archives/${backupdir##*/}.$((incremental+1)) |
injection de la sauvegarde s...
|
42 | |
version récente du script de...
|
43 |
filelist=$(mktemp --dry-run /dev/shm/XXXXXXXX) |
44 |
cat > $filelist << EOL |
|
45 |
/home/sms/bot |
|
46 |
/home/sms/bot.conf |
|
47 |
/home/sms/missed-calls |
|
48 |
/home/sms/missed-calls.conf |
|
49 |
/home/imapfilter/.imapfilter/config.lua |
|
50 |
/home/imapfilter/authorized.lua |
|
51 |
/home/imapfilter/contact@paris12.pcf.fr.lua |
|
52 |
/home/imapfilter/printscript.model |
|
53 |
/home/synapse/homeserver.yaml |
|
54 |
/root/inject |
|
55 |
/root/iptables.rules |
|
56 |
/root/iptables.norules |
|
57 |
/var/www/grav/user/themes/pcf-12 |
|
58 |
/var/www/nextcloud/config/config.php |
|
59 |
EOL |
|
60 |
rsync ${rsync_opt[@]} --files-from=$filelist / $backupdir/ >> /var/log/${0##*/} 2>&1 |
|
61 |
rm $filelist |
|
injection de la sauvegarde s...
|
62 | |
version récente du script de...
|
63 |
rsync ${rsync_opt[@]} --exclude="/etc/ssh/ssh_host_*" /etc $backupdir/ >> /var/log/${0##*/} 2>&1 |
injection de la sauvegarde s...
|
64 | |
version récente du script de...
|
65 |
rsync ${rsync_opt[@]} --exclude="plugins" --exclude="themes" /var/www/grav/user $backupdir/var/www/grav/ >> /var/log/${0##*/} 2>&1 |
66 | ||
67 |
mkdir -p $backupdir/databases |
|
68 | ||
69 |
mysqldump -u owncloud_usr --password=$(awk -F"'" '/dbpassword/{print $4}' /var/www/nextcloud/config/config.php) --skip-comments owncloud > $backupdir/databases/owncloud.db |
|
70 | ||
71 |
mysqldump -u sms --password=$(< /home/sms/secret.sms) --skip-comments sms > $backupdir/databases/sms.db |
|
72 | ||
73 |
#echo -en ".output $backupdir/databases/synapse.db\n.dump\n.quit\n" | sqlite3 /home/synapse/homeserver.db |
|
74 | ||
75 |
#echo -en ".output $backupdir/databases/synapse.schema\n.schema\n.quit\n" | sqlite3 /home/synapse/homeserver.db |
|
injection de la sauvegarde s...
|
76 | |
77 |
exit 0 |