Rsync questions

I know how to use rsync, but I dont want to mirror an exact copy of a directory
Is it possible with rsync to just save the files/directories that were created or altered with dayly intervals saved in a folder by date.
So every day say at 24h00 all files created or changed are saved in a folder etc.

Rsync used as is, will replace good files with corrupt ones so it is not an option. Having dayly copies gives me way more options with up to 365 undo’s for mission crytical files.

Anyone done something similar with rsync?

As a cheap hack, you could run rsync with the --dry-run option to list all the changed files, then copy those files to a new directory. A better solution might be to use rsnapshot which acts like rsync with incremental backups. As a more complex and robust solution, consider using a filesystem like zfs and create daily snapshots of your filesystem instantly.

2 Likes

Thank you for the great suggestions.
zfs is not an option right now as it is too many servers.
rsnapshot and all these ready made solutions can do about everything except what is needed in reality.
Thanks for the --dry-run suggestion. That combined in a bash script will work. Dont know why I didnt think about that.

I’m glad you found the suggestion helpful. Admittedly, the --dry-run solution won’t be very efficient because it will copy entire files instead of just the changed bytes. You may also need to think about files whose timestamp changed but whose contents did not, since --dry-run may list them depending on your other rsync options. Good luck.

Information on how you can achieve this result using vrangesync
don’t confuse vrangesync with rsync. they are different product.

An alternative output directory

New changes are copy/sync to alternative output directory

-aa , --aoutput

./vr -i “/home/syncuser/computerwork” -o “/backup/syncuser/computerwork” -aa “/altbackup/vault”

Differential backup

New

It will copy/sync new changes to “/backup/rdiff/rdiff_YYYYMMDD” after compare source and destination.

./vr -i “/home/syncuser/computerwork” -o “/backup/syncuser/computerwork” -aa “/backup/rdiff/rdiff_YYYYMMDD”

Restore

./vr -i “/backup/rdiff/rdiff_YYYYMMDD” -o “/home/syncuser/computerwork” --mode “restore”


An example script

Create date_directory and keep new changes

NOTE: change ‘/path/script.sh’ to your own filesystem path. The following are just an example.

$ nano /path/script.sh

#!/bin/bash
#create cronjob to automate backup
#@daily /path/script.sh >/dev/null 2>&1
now=“$(date +%Y%m%d)” # date format: YYYYMMDD
/path/to/vr -i “/home/syncuser/computerwork” -o “/backup/syncuser/computerwork” -aa “/backup/rdiff/rdiff_${now}”

$ chmod 755 /path/script.sh