0

I'm using tar to backup and restore my Ubuntu system.

For my Ubuntu system, I mount / to dev/sda1 and mount /home to dev/sda2. I want to backup or restore / without /home.

To backup, I execute

cd ~ && sudo tar -cvpzf backup.tar.gz --exclude /home --one-file-system /

Then I install some packages, for example, apt install ubuntu-desktop.

Now I want to restore my system with backup.tar.gz. So I execute

sudo tar -xvpzf backup.tar.gz -C / --numeric-owner

My questions are:

  1. Will this remove all files from apt install ubuntu-desktop?

  2. Will this touch my home folder? I'm wondering if this will clean all files in my home folder.

  • As far as I can see, no (both questions). – Kusalananda Mar 23 '18 at 7:59
1

When you use it to extract a tarball, tar (by default) doesn’t delete files. This largely answers both your questions: the files added by installing ubuntu-desktop will be untouched, as will the contents of /home. Extracting the backup will however restore any files the tarball contains, which means the system’s package databases will be returned to their state before you installed ubuntu-desktop.

If you want to have a fully reversible package installation, you should use snapshots instead.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.