Posted By Irfad

Rsync Script With File Versioning by Date

This script I’m using on my file server when mirroring the data from primary hard drive to backup and external hard drive. Which basically checks for the files which have been modified or deleted on primary by comparing backed up data on the backup drive and then move the unmodified and undeleted files from backup drive to a separate directory organized by date on every sync run.


  1. File A,B,C on primary synced with backup drive
  2. Modifying A and Delete B on primary. Unchanged files remain in the backup drive
  3. When running sync, files A and B are moved to a new directory from backup drive

Rsync script

rsync -v -r –backup –delete –backup-dir=/data/version/`date +%Y.%m.%d` -a /data/source /media/backup

/data/version/`date +%Y.%m.%d` – Is the version folder and move and keep the files by date inside the directory

/data/source – Is the source

/media/backup –  Is destination


View Comments
View Comments
There are currently no comments.

This site uses Akismet to reduce spam. Learn how your comment data is processed.