Linux – get rsnapshot to create LVM snapshots on a remote machine

backuplinuxlvmrsnapshotssh

I'm currently running rsnapshot on host1, backing up some files from host2 using the inbuilt SFTP support (I have daily, weekly, and monthly backups running in a standard rsnapshot configuration). Both hosts are running Ubuntu and use LVM. Is there any straightforward way I can create and mount LVM snapshots on host2 to back up from, before a backup run is started, and delete them afterward, to increase the consistency of the set of files that are backed up? It looks like more recent versions of rsnapshot have LVM support built in using the linux_lvm_* commands, but that only seems to work when backing up from the same host, which I'm not doing. Ideally the mechanism ought to be fairly failure redundant, i.e.:

  • The LVM snapshots on host2 should be deleted after the backup is completed, whether it was successful or not.
  • If a snapshot cannot be created, the backup doesn't proceed.

Best Answer

Maybe you are asking too much from a single rsnapshot instance. Why don't you use a script on host2 to create the snapshot, including the creation of a report and a flag, and then let rsnapshot from host1 do it's part depending on the presence of the flag ?

I usually create the backup locally then let the backup server grab it through an NFS mount, but it depends on the available space on host2 of course.