0

I am using rsync and crontab to schedule a nightly backup.

However, want to do a full-backup and not incremental.

I am using the following rsync in my script file.

rsync -razv dev@xx.xx.xx.xx:repos /home/backup_sys_user/repos_backup

And I want to create the structure below:

/repos_backup/10.10.2010
             /11.10.2010
             /12.10.2010

Is there anyway rsync can do this. I know if can create the directory using the --backup-dir=DIR but this is only for incremental. I want to do a full backup.

Many thanks for any advice,

ant2009
  • 149
  • 2
  • 3
  • 10
  • The output directory for rsync always contains a full backup. It applyies the incremental changes since the last backup to existing backups. There are backup options which will create historical backups. – BillThor Oct 10 '10 at 21:24

2 Answers2

3
DATE=`date +%m.%d.%Y`
rsync -razv dev@xx.xx.xx.xx:repos /home/backup_sys_user/repos_backup/$DATE

However, you might want to look at using --link-dest which will create backups with hardlinks, then, deleting older backups will still leave you with a full copy, but, you'll only take up the disk space for the changed files.

karmawhore
  • 3,865
  • 18
  • 9
  • 1
    If this is only one command, you could just enter the date inline also `rsync -razv dev@xx.xx.xx.xx:repos /home/backup_sys_user/repos_backup/$(/bin/date +%m.%d.%Y)` – Alex Oct 10 '10 at 17:21
2

karmawhore has it generally right, but instead of manually using "--link-dest", you may want to check out rsnapshot:

http://rsnapshot.org/

Also, for large numbers of files I'd recommend using a version of rsync in the 3.x range because of this key improvement:

- A new incremental-recursion algorithm is now used when rsync is talking
  to another 3.x version.  This starts the transfer going more quickly
  (before all the files have been found), and requires much less memory.
  See the --recursive option in the manpage for some restrictions.