0

I have a directory which I wish to backup. However, a process is constantly writing to files in that directory and I cannot shut down this process, do the backup and restart the process. The backup has to be done when this process is running. How may I use the rsync command line flags/options to backup a snapshot of this directory without losing much data? There are so much options for rsync i am confused which combinations can be use for this purpose.

thanks

closed as off-topic by EEAA, mdpc, Scott Pack, peterh, masegaloeh May 10 '15 at 3:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

3

AFAICT rsync on it's own can't do this.

Switch the system to use LVM/ZFS/btrfs/something else with snapshots, mount the snapshot, and rsync that. Then remove the snapshot.

For example, with LVM:

# Allow 1GB of changes to occur while the rsync occurs
lvcreate --snapshot my_vg/my_lv --size 1GB --name backup
mount /dev/my_vg/backup /mnt/temp
# ... rsync goes here ...
# e.g. rsync /mnt/temp/srv/my/path remote:/srv/backups/$( date -I )
umount /dev/my_vg/backup
lvremove my_vg/backup

In a VM this most easily takes place outside the VM itself and is vendor specific - you'd need to look at that for whatever VM environment you were using.

Not the answer you're looking for? Browse other questions tagged or ask your own question.