I have found that I need this command to make a full backup of the Etc folder

tar cJPf /srv/dev-disk-by-label-Share/Myfiles/$(date +%F)-$(hostname)-etc-tar.xz /etc/ 

But what command do I need to restore this backup to a new installation?

And what about preserve symlinks? -When I can see it important when you take a backup of letsencrypt under the folder etc


From 'tar' man page:

-h, --dereference follow symlinks; archive and dump the files they point to

In order to extract it (and preserve the symlinks), on a Ubuntu system for example, you'd do the following after making sure 'xz-utils' package is installed:

tar xhf name.tar.xz

where 'name' is your filename created in the first step that you mentioned.

  • Should I be in the folder "etc" I would like to restore when I type that command? – Rene Mortensen Nov 2 '18 at 13:58
  • Not necessarily, you can use tar xhf name.tar.xz -C /etc to put the contents of extracted archive in /etc. – sla3k Nov 2 '18 at 16:34
  • Thanks :) - What does -C mean? :) – Rene Mortensen Nov 2 '18 at 18:05
  • From the man page, -C dir changes to the directory provided (in this case /etc) before extracting the contents of an archive; and then run the tar command which will extract the contents into present working directory (which is the same directory to which -C flag cd'd into; /etc in this case). – sla3k Nov 2 '18 at 18:23

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.