rsync question
Hi,
I am using Mandriva 2007. I wanted to get a basic working solution for backing up my data. So i am using Rsync to take backups of my internal drive on my external USB drive. i am using rsync with --delete switch, which removes the files from the backup, that have been removed from the source. Now i was wondering, if it is possible to configure rsync to instead of deleting such files, it should move them to a separate folder. Like for example, it should synchornize the source with destination, and the files that have been deleted, should be moved to a "deleted files" directory. Any suggestions on how it may be done. |
Hi,
don't think that rsync provides such feature. Don't know exactly, but it could be possible that the ouput of a dry rsync run provides enough information to extract the files that would become deleted by a real run. You can move them by script before starting the real rsync run. Not that handy, I know ;-) |
well it is an idea nevertheless.. i'll try that tonight ...
|
Like the above poster said, you can diff command to compare directories, move the directories that don't match between source and destination and then run rsync.
|
Hi
Another option is to install the program "rdiff-backup". Instead of deleting the files that have been deleted (or changing the changed files) it automaticly puts diffs so you can recreate backup from any time. Most distros should have rdiff-backup, you just need to install it. To make a backup, e.g.: rdiff-backup /home /mnt/usbdisk /mnt/usbdisk/home will be a plain copy /home but it will have a special directory called "rdiff-backup-data" in it with diffs for files deleted or changed. If you run that command a few times, you can try: rdiff-backup -l /mnt/usbdisk This will give you a list of all the times you have taken backups. Any of them can be restored using rdiff-backup --restore-as-of TIME /mnt/usbdisk /tmp Because the usb disk will fill up with diffs if the files change a lot, you need to delete very old diffs. This will remove diffs older than 32 days: rdiff-backup --remove-older-than 32D In sum: I think rdiff-backup is really neat - having all the benefits of rsync plus the ability to keep files even if they are changed or deleted. |
Hi.
Quote:
The option that controls this is: Quote:
Code:
Backup date = Fri Mar 9 02:05:02 CST 2007 Code:
rsync -abv $mode --backup-dir=$BACKUPDIR --delete \ Best wishes ... cheers, makyo |
If the goal are incremental backups (instead of a directory containing all deleted files as the OP wrote), you can use tools like dirvish (command line) or backuppc (daemon with cgi-interface).
Both use rsync (backuppc knows other "treansports", too) to keep a remote dir in sync, storing only changed files. Files that did not change become hardlinked and don't need additional space on the disk. You get "snapshot like incrementals" in a comfortable manner. |
Hi, Clemente.
My scheme does not capture deleted files, only the originals for files scheduled to be replaced. Apologies if I mislead anyone. It does appear to me that option -b, --backup is intended to keep transferred or deleted files: Quote:
|
Hi.
Indeed, rsync is able to copy files that would be deleted. The heart of this is a command such as: Code:
rsync -abv --delete --backup-dir=$B --suffix=.orig $S/ $D/ If this is of interest, I can post the test script and the results ... cheers, makyo |
Thanks a lot guys....
And yes makyo, i would really appreciate if you can post the test scripts etc. That would really be helpful. And soory for replying late, but my net was down for the past two days... |
Hi, mkhan919.
OK, here it is. There are some debugging aids built-in so that you can turn on and off explanatory messages. A number of files are created in the source directory. These are copied to the destination directory. The dates of files in the latter are adjusted by the odd call to touch so that they will appear to be older to rsync, and thus be candidates for copying. One file in source will be deleted to create the situation where rsync will schedule the file for deletion in the destination. The final result is that all files are updated, the two directories are synchronized, and the originals and the one deleted file will be placed in the backup directory. To emphasize that placement, I added a suffix for the filenames. A recursive diff shows that the only item different is the backup directory. The output from the script should illustrate these points. Best wishes ... cheers, makyo Code:
#!/bin/sh Code:
% ./s1 |
All times are GMT -5. The time now is 01:01 AM. |