Backing up ecryptfs on an LV

Because I know I will forget this in the future:

# create the LV snapshot
hodor ~ # lvcreate -L5G -s -n backup-home /dev/hodor/home
  Logical volume "backup-home" created

# create the mount point and mount the snapshot
hodor ~ # mkdir /mnt/blah
hodor ~ # mount /dev/hodor/backup-home /mnt/blah

# mount ecryptfs and go to where it tells you to go
hodor ~ # ecryptfs-recover-private /mnt/blah/.ecryptfs/david/.Private/
INFO: Found [/mnt/blah/.ecryptfs/david/.Private/].
Try to recover this directory? [Y/n]: y
INFO: Found your wrapped-passphrase
Do you know your LOGIN passphrase? [Y/n] y
INFO: Enter your LOGIN passphrase...
Inserted auth tok with sig [<OMITTED>] into the user session keyring
INFO: Success!  Private data mounted at [/tmp/ecryptfs.UahEKdmV].
hodor ~ # cd /tmp/ecryptfs.UahEKdmV/

# backup the damn thing
hodor ecryptfs.UahEKdmV # tar --one-file-system --exclude=.Private --exclude=.cache -pScvzf /home/david/homebackup.tar.gz .

# now clean up this mess
hodor ecryptfs.UahEKdmV # cd
hodor ~ # umount /tmp/ecryptfs.UahEKdmV
hodor ~ # umount /mnt/blah
hodor ~ # rmdir /mnt/blah
hodor ~ # lvremove /dev/hodor/backup-home 
Do you really want to remove and DISCARD active logical volume backup-home? [y/n]: y
  Logical volume "backup-home" successfully removed

Then throw the backup somewhere. Done.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>