2 # if we get an error, keep going but return it at the end
4 trap 'last_error=$?' ERR
6 # No strict because the host is likely not named the same as
8 ssh="ssh -oStrictHostKeyChecking=no"
9 logfile
=/var
/log
/${mwdomain}_backup.log
11 echo "#### starting backup at $(date) ####"
12 $ssh root@
$mwdomain <<ENDSSH
15 \$wgReadOnly = 'Dumping Database, Access will be restored shortly';
17 mkdir -p ~/wiki_backups
18 mysqldump -p$dbpass --default-character-set=binary my_wiki > ~/wiki_backups/wiki_db_backup
19 sed -i '\$ d' $mwc # delete read only setting
21 # add no strict option to the defaults
23 rdiff
() { rdiff-backup
--remote-schema "$ssh -C %s rdiff-backup --server" "$@"; }
25 rdiff root@
$mwdomain::/root
/wiki_backups ~
/backup
/${mwdomain}_wiki_db_backup
26 rdiff root@
$mwdomain::$mw ~
/backup
/${mwdomain}_wiki_file_backup
28 echo "=== ending backup at $(date) ===="
30 if [[ $last_error != 0 ]]; then
31 echo "backup for $mwdomain failed. See $logfile"