6

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      root@host.mydomain.net:/etc/        host.mydomain.net/
    backup      root@host.mydomain.net:/srv/www/        host.mydomain.net/
    backup_script       /usr/bin/ssh root@host.mydomain.net "rm -rf /var/local/mysqlbak/"       unused/
    backup_script       /usr/bin/ssh root@host.mydomain.net "/usr/local/bin/mysql_bak.sh"       unused1/
    backup      root@host.mydomain.net:/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" myemail@domain.com
 30     3     * * *    root    /usr/bin/rsnapshot daily 2>&1  | \/usr/local/bin/rsnapreport.pl | mail -s "Daily Backup" myemail@domain.com
 0      3     * * 1    root    /usr/bin/rsnapshot weekly 2>&1  | \/usr/local/bin/rsnapreport.pl | mail -s "Weekly Backup" myemail@domain.com

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" myemail@domain.com

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.

1
  • I don't know which version of rsnapshot you have but reading the man rsnapshot in section sync_first you could see that you can enable it into rsnapshot.conf instead of adding it into your cron job Nov 28, 2018 at 11:25

1 Answer 1

3

You have to call rsnapshot sync before calling rsnapshot <level>.

2
  • Could you comment a bit more the reason of calling this before? Nov 28, 2018 at 11:11
  • If you set sync_first 1 it means that you take responsibility for calling rsnapshot sync manually before calling the other retention levels. Calling the other levels simply rotates the files and without any sync (because you told it you'd manually call sync first). Apr 16, 2021 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.