Backup - which directories

Latest response

Hello

I need a perform backup for crucial directories by tar:

tar -czvf /root/backup/arch_etc.tar.gz /etc/
tar -czvf /root/backup/arch_home.tar.gz /home/
tar -czvf /root/backup/arch_opt.tar.gz /opt/
tar -czvf /root/backup/arch_root.tar.gz /root/
tar -czvf /root/backup/arch_usr_local.tar.gz /usr/local

Do I need to backup something more?

My regards
Tomasz

Responses

Hi Tomasz,

Depends on what you want to backup ... if you want get sure that everything is covered, backup the entire system. :)
Example root volume : sudo tar --acls --selinux --xattrs -cvzpPf /<path-to-backup>/root.tar.gz /

Regards,
Christian

All,

sudo tar --acls --selinux --xattrs -cvzpPf /<path-to-backup>/root.tar.gz --exclude /<path-to-backup> /

otherwise you might create a loop.

In general it is bad practise:

  • to backup the backup directory itself.
  • put backups in a sub directory of /root

Regards,

Jan Gerrit

Thanks for the hint Jan Gerrit, good idea to add --exclude ... generally I don't recommend to perform such
operations from within a running system. I recommend to boot from a live medium like GParted - and then
create two mount points, one for the system and one for the backup location, and perform it from there. :)

Example :

sudo mkdir /temp1
sudo mkdir /temp2

sudo mount /dev/rhel/root /temp1
sudo mount /dev/sdb1 /temp2

sudo tar --acls --selinux --xattrs -cvzpPf /temp2/root.tar.gz /temp1

Regards,
Christian