Peterborough Linux User Group (Canada) Forum

Linux & Android => Support => Topic started by: ssfc72 on March 06, 2021, 08:52:16 PM

Title: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: ssfc72 on March 06, 2021, 08:52:16 PM
So I am trying to use the trick that Buster uses, to save the Home folder of a Distro, in order to re-install it back again in the same Distro, after a re-install or upgrade.

I am using the the GUI of the File manager in my Mint 19.1 Distro and when I try to save the Mint Home folder to a potable usb hdd, I get a message saying something like "cannot copy folder .gvfs, no permission to read".

Can someone give me the exact details, on how I go about storing a copy of my Mint Home folder on a usb hdd, so that I can copy it back to a new install of Mint 19.1???

Thanks!
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: fox on March 06, 2021, 08:56:43 PM
Can't you use Timeshift to save your Home folder?
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: William on March 06, 2021, 11:40:18 PM
1. Log in as root, and try copying your home directory.

2. Or, do it on command line.
cp -a /home/user /mnt/usb

3. Use separate partition for /home.
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: ssfc72 on March 07, 2021, 05:22:27 AM
Thanks for your help, William and Mike.

With the Mint Distro, I don't think you can log in as a Root user. I think you can only use the sudo command, in the Terminal, to get Root privileges?

The command line that you suggest, would I have to specify what usb, the portable usb hdd is?  ie  usb sdc1?

Also, I just remembered about right clicking on the Files slection in the Mint menu, to select Root privileges.   I did this and got "elevated" privledges, but I still got the complaint, "cannot copy folder, no permission to read". :-(

So, I remembered about using Puppy Linux and I booted up Puppy from a usb flash drive and had no problem copying the Mint Home folder to the portable usb hdd. :-)  Way to go, Puppy Linux. :-) 
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: fox on March 07, 2021, 08:05:00 AM
I'm curious why you didn't try Timeshift. It comes installed with Mint.
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: ssfc72 on March 07, 2021, 09:13:49 AM
I am not familiar with how Timeshift works and I don't know if it would allow, only the Home folder to be restored or if Timeshift allows you to save to a portable usb hard drive, etc.
Where is Timeshiift found? It doesn't come up when I do a search for a program on the Mint menu?

Edit:  I went to Synaptic and installed Timeshift.  Unfortunately, I found that Timeshift says it can not put the Timeshift backup file, on a hdd that is formatted with the Microsoft file system. :-(   So that is a deal breaker, right there for me, since all my usb flash drives and portable external usb drives are formatted with a Windows file system.
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: fox on March 07, 2021, 11:50:38 AM
I think I was partly wrong about Timeshift. I thought it was automatically installed with Mint 19 and up, but maybe not if you were upgrading an older version. In any event, it takes system snapshots, so it isn't the right tool for backing up your home folder. However, Mint has another tool that looks appropriate for that, called Mintbackup. Also, I would think that the Ubuntu tool, called either Deja dup or Backup, would also work. Any of them should be able to be set to back up on an external drive.  But if Puppy worked for you, you don't need any of these others unless you want to make current backups of your Home folder within Mint itself.
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: Jason on March 07, 2021, 12:07:23 PM
Personally, I don't use Timeshift for home backups. I use it for system backups (just the / not including /home). Now, to solve your issue...

Many distros seem to mount external drives with root permission to write to them but you can read them fine. It bugs me. Your error seems to suggest a read error (from your home drive??). Regardless, the easiest way around it is to change the permissions of wherever you have the drive mounted to your user. The easiest way to do that is using the command-line. So, first, find out where your drive is mounted. You can do this graphically or by using the CLI. Now let's change the permissions:

sudo chown -R billy:billy /path/to/drive

- replace billy with whatever your username is and /path/to/drive to... should be obvious

That should be enough to let you write to the drive. But if not, you might also have to run:

sudo chmod -R 777 /path/to/drive

What I do is a bit different. Just so I don't have this annoying error in the future, I actually change the permissions of the upper folder where external drives are usually mounted (i.e. /media/billy) and then anything inserted should let me write and read from it. So here's how I do it as an example:

Quotesudo chown -R jason:jason /media/jason
sudo chmod -R 777 /media/jason

What Buster is saying is that when he installs a distro, he puts /home on its own partition. That way when you install a new distro, you just mount that partition as /home and away you go! No backup is necessary although you should still do that.

Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: Jason on March 07, 2021, 12:14:09 PM
An easy way to find where it's mounted, assuming you know the size of it, is to run df like this:

df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           384M  3.1M  381M   1% /run
/dev/sda1       117G   66G   46G  59% /
tmpfs           1.9G  171M  1.8G   9% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           384M   24K  384M   1% /run/user/1000
/dev/sdb1        57G   25G   29G  47% /media/jason/4f3fdfdc-37b5-49f5-b977-e26a0c5c5be3


Therefore, I know that the USB drive connected to it is 64 GiB (sold in GiB but OSes show it in GB hence, the 57 GB shown)

Now you know where to copy the files. Note it's the drive name as listed on the right, not the left (i.e. NOT /dev/sdb1 in this case)
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: William on March 07, 2021, 01:56:05 PM
Quote from: ssfc72 on March 07, 2021, 09:13:49 AM
Edit:  I went to Synaptic and installed Timeshift.  Unfortunately, I found that Timeshift says it can not put the Timeshift backup file, on a hdd that is formatted with the Microsoft file system. :-(   So that is a deal breaker, right there for me, since all my usb flash drives and portable external usb drives are formatted with a Windows file system.
If Puppy just copied the directories, then you lost all the intricate permissions and other metadata of Linux filesystems.  Correct way, is to tar it up and save the tarball, which I doubt Puppy did.

Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: William on March 07, 2021, 02:12:46 PM
Quote from: ssfc72 on March 07, 2021, 05:22:27 AM
The command line that you suggest, would I have to specify what usb, the portable usb hdd is?  ie  usb sdc1?
You have to mount it first.  So, assuming /dev/sdc1 is the partition of external USB/HDD,

mount /dev/sdc1 /mnt/usb
cp -ax /home/user /mnt/usb

It will copy "user" directory to "/mnt/usb" directory, so you'll get /mnt/usb/user.  I added -x option (explained below).

Quote from: ssfc72 on March 07, 2021, 05:22:27 AM
Also, I just remembered about right clicking on the Files slection in the Mint menu, to select Root privileges.   I did this and got "elevated" privledges, but I still got the complaint, "cannot copy folder, no permission to read". :-(
Main reason of your trouble is that ~/.gvfs is mounted directory.  You can see by

$ mount
gvfsd-fuse on /home/user/.gvfs type fuse.gvfsd-fuse (...)

It's GNOME thing, but it's mounted even on KDE desktop like mine.  So, you have to skip that when copying (hence -x option).  Or, you can shutdown your desktop or boot up in terminal mode, then you don't need -x option.
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: ssfc72 on March 07, 2021, 08:40:35 PM
Thanks guys for the help.  That info is good to know.
Title: Re: Need help on how to save the Home folder if a Distro, for re-installing later
Post by: ssfc72 on March 07, 2021, 09:58:10 PM
Update.

Ok, I was successful in re-installing the Home folder of my Mint 19.1, on my notebook computer. 🙂

I booted up Puppy Linux from a usb flash drive on my Mint computer and I then deleted the Mint Home folder on the notebook computer and then re-installed the Home folder from a copy of the Mint Home folder that I stored on another usb hdd.
It took quite a few minutes for all the files to be copied back to the Home folder.

The Mint notebook works like nothing ever happened to the Home folder.