Rsync to create directory based on date

backuprsync

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,

Best Answer

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.