ecryptfs How To Backup / Migrate Linux Mint Ubuntu Debian system ecryptfs properly and restore access

In this scenario, let's say you want to clone your OS at the filesystem level and the source system (the system you want to clone from) is in use.

Doing a blind rsync / is a big problem because it uses twice as much space for no reason.

The reason for this is that with ecryptfs you have a /home/.ecryptfs directory which has the actual encrypted versions of your files and folders. However your home directory (eg. /home/someuser) is mounted.

Doing the blind rsync will cause you to backup the mounted actual files and the actual encrypted files, which is how your data is doubled. 

How an unmounted ecryptfs home directory looks

We can see that all that's really contained in the home directory are two symlinks .ecryptfs and .Private which link to /home/.ecryptfs/easy/.ecryptfs and /home/.ecryptfs/easy/.Private

How would we backup our ecryptfs system then?

You would want to do something like this:

replace "--exclude=/home/easy" with the path of your home directories (and add more excludes for each user under home that has ecryptfs files).

rsync -Phaz / --exclude=/home/easy/ --exclude=/proc/* --exclude=/sys/* user@remotehost:/mnt/target

On the target system though we'll need to create the symlinks again:

This assumes your entire filesystem has been stored in /mnt/target (change this path to where your target was transferred to)

chroot /mnt/target

Now we create the symlinks.

Now change to the user's directory where you need this done.

#change /home/easy to your user dir

cd /home/easy

 

Change "ln -s /home/.ecryptfs/easy" to the name of your user eg . "ln -s /home/.ecryptfs/yourusername"

ln -s /home/.ecryptfs/easy/.ecryptfs .ecryptfs

ln -s /home/.ecryptfs/easy/.Private .Private

 

Ecryptfs Success

Once you login again, you should now have restored access to all of the encrypted files, assuming that you did your backup correctly and that /home/.ecryptfs was copied properly from the source system.


Tags:

ecryptfs, migrate, linux, mint, ubuntu, debian, restore, accessin, clone, os, filesystem, rsync, directory, encrypted, versions, folders, eg, someuser, mounted, doubled, unmounted, contained, symlinks, quot, exclude, directories, excludes, user, phaz, proc, sys, remotehost, mnt, ll, assumes, stored, chroot, sudo, ln, yourusername,

Latest Articles

  • How To Upgrade Debian 8,9,10 to Debian 12 Bookworm
  • Linux dhcp dhclient Mint Redhat Ubuntu Debian How To Use Local Domain DNS Server Instead of ISPs
  • Docker dockerd swarm high CPU usage cause solution
  • Docker Minimum Requirements/How Efficient is Docker? How Much Memory Does Dockerd Use?
  • qemu-nbd: Failed to set NBD socket solution qemu-nbd: Disconnect client, due to: Failed to read request: Unexpected end-of-file before all bytes were read
  • apache2 httpd apache server will not start [pid 22449:tid 139972160445760] AH00052: child pid 23248 exit signal Aborted (6) solution Mint Debian Ubuntu Redhat
  • How to use the FTDI USB serial cable to RJ45 adapter to connect to the console on Cisco/Juniper Switch Router Firewall in Linux Ubuntu Debian Redhat
  • How To Setup Python3 in Ubuntu Docker Image for AI Deep Learning
  • How to Configure NVIDIA GPUs with Docker on Ubuntu: A Comprehensive Guide for AI Deep Learning CUDA Solution
  • Linux Ubuntu Mint how to check nameservers when /etc/resolv.conf disabled solution
  • Docker cannot work on other overlayfs filesystems such as ecryptfs won't start overlayfs: filesystem on '/home/docker/overlay2/check-overlayfs-support130645871/upper' not supported as upperdir
  • Linux How To Access Original Contents of Directory Mounted Debian Mint CentOS Redhat Solution
  • ecryptfs how to manually encrypt your existing home directory or other directory
  • How to Reset CIPC Cisco IP Communicator for CME CUCM CallManager
  • Internet Explorer Cannot Download File "Your security settings do not allow for this file to be downloaded." Security Settings Solution
  • Linux How To Upgrade To The Latest Kernel Debian Mint Ubuntu
  • Firefox how to restore and backup saved passwords and history which files/location
  • Linux How To echo as root solution to use tee permission denied solution Ubuntu Debian Mint Redhat CentOS
  • Linux how to keep command line bash process running if you are disconnected or need to logout of SSH remotely
  • Linux swapping too much? How to check the swappiness and stop swapping