Rsync mounted snapshot

General support questions including new installations
Post Reply
funnyfingers
Posts: 59
Joined: 2011/07/20 19:39:11

Rsync mounted snapshot

Post by funnyfingers » 2011/12/27 16:31:36

I wrote a script to tar, gzip, and encrypt the root LV by doing a snapshot and killing the snapshot when complete. I had this for multiple LVs on the system. I now want to use RSYNC over SSH. Can I do a similar thing? I want to just do a snapshot, mount it, and then do the RSYNC and it should be pretty quick once the first is done.

milosb
Posts: 661
Joined: 2009/01/18 00:39:15
Location: 44 49′14″N 20 27′44″E

Re: Rsync mounted snapshot

Post by milosb » 2011/12/28 00:30:40

Maybe I misunderstood your question, but, to be honest, I don't fully understand what the problem is. Rsync uses SSH as its remote shell program by default - and an alternative remote shell program can be specified on the command line by specifying the [b]-e[/b] argument.

Regards,

funnyfingers
Posts: 59
Joined: 2011/07/20 19:39:11

Re: Rsync mounted snapshot

Post by funnyfingers » 2011/12/28 01:41:51

I just have never done rsync before so I wasn't sure how it would work with a mounted LV.

Here is what I have done so far:

mkdir -p /mnt1/mnt_rsync/VolGroup00-LogVol00
lvcreate -L592M -s -n VolGroup00-LogVol00-rsync /dev/VolGroup00/LogVol00
mount /dev/VolGroup00/VolGroup00-LogVol00-rsync /mnt1/mnt_rsync/VolGroup00-LogVol00
rsync -a -e ssh /mnt1/mnt_rsync ac12345@10.10.10.15:~/
umount /mnt1/mnt_rsync/VolGroup00-LogVol00
lvremove /dev/VolGroup00/VolGroup00-LogVol00-rsync

I have to do some more testing and may need a more specific destination as I will be doing this with about 10 or more other LVs.

milosb
Posts: 661
Joined: 2009/01/18 00:39:15
Location: 44 49′14″N 20 27′44″E

Re: Rsync mounted snapshot

Post by milosb » 2012/01/02 22:19:23

I haven't dealt with LVM snapshots in a while, and when I did, the amount of work was minute, hence, I can't help you there much.

However, from what you've written so far, I don't see a reason for this not to work rsync-wise.

ixeous
Posts: 113
Joined: 2005/07/07 13:01:59

Rsync mounted snapshot

Post by ixeous » 2012/01/03 14:21:28

Yes, this can be done. The line in the script will look something like

rsync -e "ssh -l root" -a /etc/scripts /etc/exports $REMOTEHOST:/etc

I have a script which does the same thing for data volumes and it works nicely. The data does not use ssh because using rsync daemon is MUCH faster than ssh. Below is the portion of my script that handles such things. Each volume gets it's own snapshot name and mount point because I did run into a situation where 2 instances of the script were running and it caused problems with the backups.

# start rsync in daemon mode on remote system
ssh root@$REMOTEHOST "rsync --daemon &"

for vol in $(ls -1 /data); do
# create snapshot volume
/usr/sbin/lvcreate -s -l 16220 -n LVsnap$vol /dev/VGdata/LV$vol
# create direcotry to mount the snapshot if it does not exist
if [ ! -d /data/.snap.$vol ]; then
mkdir /data/.snap.$vol
fi
mount /dev/VGdata/LVsnap$vol /data/.snap.$vol

# perform sync
rsync -a --delete /data/.snap.$vol/ $REMOTEHOST::data/$vol

# remove snapshot
umount /data/.snap.$vol
/usr/sbin/lvremove -f /dev/VGdata/LVsnap$vol
done

# stop rsync in daemon mode on remote system
ssh root@$REMOTEHOST "killall rsync"

Post Reply