Using Rsnapshot with sync_first, link_dest, and use_lazy_deletes
I've set up rsnapshot with the configuration below and it seems to work fine. However, if I understand what I have read correctly, in the rsnapshot docs and other tutorials, the operation would be more robust with these options added:
link_dest 1
sync_first 1
use_lazy_deletes 1
However when I enabled these, particularly sync_first, it does not seem to operate correctly. There are no errors, but nothing seems to happen (see last code block below). Configtest succeeds fine. I suspect I am missing something about how sync_first is to be used. I would like to know first if these three options are indeed beneficial when used together (no conflicts) and secondly, is there a difference in the way I must call rsnapshot in cron after enabling sync_first?
This is installed on Ubuntu 14.04 with rsnapshot 1.3.1 and rsync has the link_dest option. Thanks for any direction on this, the official docs are a bit dry.
Conf
config_version 1.2
snapshot_root /srv/rsnapshot/
no_create_root 0
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
retain HoursAgo 6
retain DaysAgo 7
retain WeeksAgo 4
#retain monthly 3
verbose 5
loglevel 3
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
rsync_long_args --stats --delete --numeric-ids --relative --delete-excluded
ssh_args -p 22
# host.mydomain.net
backup [email protected]:/etc/ host.mydomain.net/
backup [email protected]:/srv/www/ host.mydomain.net/
backup_script /usr/bin/ssh [email protected] "rm -rf /var/local/mysqlbak/" unused/
backup_script /usr/bin/ssh [email protected] "/usr/local/bin/mysql_bak.sh" unused1/
backup [email protected]:/var/local/mysqlbak/ host.mydomain.net/mysql/
Cron
0 */4 * * * root /usr/bin/rsnapshot hourly 2>&1 | \/usr/local/bin/rsnapreport.pl | mail -s "Hourly Backup" [email protected]
30 3 * * * root /usr/bin/rsnapshot daily 2>&1 | \/usr/local/bin/rsnapreport.pl | mail -s "Daily Backup" [email protected]
0 3 * * 1 root /usr/bin/rsnapshot weekly 2>&1 | \/usr/local/bin/rsnapreport.pl | mail -s "Weekly Backup" [email protected]
Results of running with all three extra options enabled:
root@backup:~# rsnapshot HoursAgo
require Lchown
Lchown module loaded successfully
Setting locale to POSIX "C"
echo 3567 > /var/run/rsnapshot.pid
mv /srv/rsnapshot/HoursAgo.3/ /srv/rsnapshot/HoursAgo.4/
mv /srv/rsnapshot/HoursAgo.2/ /srv/rsnapshot/HoursAgo.3/
mv /srv/rsnapshot/HoursAgo.1/ /srv/rsnapshot/HoursAgo.2/
mv /srv/rsnapshot/HoursAgo.0/ /srv/rsnapshot/HoursAgo.1/
No directory to delete: /srv/rsnapshot/_delete.3567
rm -f /var/run/rsnapshot.pid
/usr/bin/logger -i -p user.info -t rsnapshot /usr/bin/rsnapshot HoursAgo: \
completed successfully
This happens instantly, with no connection to the remote and no time to check changed files.
Update: I found some additional information on sync_first in the Ubuntu pages on rsnapshot. I've edited my cron by adding rsnapshot sync &&
in front of the hourly
line:
0 */4 * * * root /usr/bin/rsnapshot sync && /usr/bin/rsnapshot hourly 2>&1 | \/usr/local/bin/rsnapreport.pl | mail -s "Hourly Backup" [email protected]
This seems to work when I ran it manually.
I would still like to know: Are these three extra options advantageous used together?
I may also dump the stats so I only get an email in case of error.
Solution 1:
You have to call rsnapshot sync
before calling rsnapshot <level>
.