Need assistance with backing up and restoring home directory after reinstall

Hi there, I want to do a reinstall and keep my files from my home directory safe and carry them over to the new install. I think I know roughly to do but there are some points I am uncertain of and would really appreciate any guidance / advice. Thanks in advance and please let me know if I should provide more information of my system.

Some info regarding the system

My lsblk looks like this:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    1     0B  0 disk
nvme0n1     259:0    0 931.5G  0 disk
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0 922.2G  0 part /var/cache
│                                     /var/log
│                                     /home
│                                     /
└─nvme0n1p3 259:3    0   8.8G  0 part [SWAP]
nvme1n1     259:4    0 238.5G  0 disk

My first drive is partitioned with BTRFS.
The second drive “nvme1n1” is currently empty since I just zero’d it using dd if=/dev/zero of=/dev/nvme1n1. I’m pretty sure I’ll have to do some formatting to the first before doing what I describe below, but am not sure what needs to be done.

I want to do the following:

  • Copy current /home to second “Back-up” drive using the following command (i am uncertain of the destination directory currently shown as “/dev/nvme1n1”
    sudo rsync -a --info=progress2 --exclude=".local" --exclude=".config" --exclude=".cache" /home/ /dev/nvme1n1
  • Reinstall EOS on my main drive.
  • Copy my /home directory back onto my main drive with:
    sudo rsync -a --info=progress2 /dev/nvme1n1/ /home/

The result I hope to obtain is for my current home directory to be safe on the new install while maintaining the default configs from the new install.

I apologize for the extremely basic request but I want to be sure what I’m doing is correct to avoid losing all my important files in my /home

Correct. The drive needs to be formatted as ext4 and mounted afterwards via fstab.

After rebooting, make sure to check if the new drive is mounted correctly. You could then create a folder on the new drive to your liking, e.g. as home-backup.

In one of my first posts on this board, I showed a script for backing up folders in side of my home:

May be this helps a bit. Take note of the tar command, as it preserves all rights of the original files.

You might also prefer to use a dot-file handler utility for the backup / restore job.

Unless you have other need for it…get the second drive setup and get your /home data on it. Then, when you reinstall, during setup have it mount your second drive as /home, leaving the first drive for /. This way your home drive is on a second drive which has all kinds of benefits (like not having to move it around when you reinstall)

Thanks for the response, how would I go about doing this? I’m currently on btrfs but not sure if it’s the right filesystem for me. Does filesystem even matter for this?

I’m assuming I would just do as @anon11595408 said in the start of his response to copy the /home across, but what do I do after that to mount the /home? Does it happen during the install process or do I do it post install?

Sorry for all the questions and thanks again for the response.

Hi, thanks for the response!

Does this mean that even though my filesystem is currently btrfs, I should still format the backup drive as ext4 ? Will this not cause issues when copying across the /home from a btrfs drive to ext4 ?

Not when using rsync. With btrfs, I’m not sure how to go about creating snapshots of your home, but I think this is not what you want…

Ext4 will safely work for your backup intention of files inside home. Btrfs may even work the same, but I have no way to prove it from here.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.