Skip to Content

Backup your Linux machine

To backup the content of your /, the simplest solution is to create an archive file and to compress it eventually.

The following command creates a compressed archive file from the / folder by excluding specific paths.

tar -cvpzf /$(cat /etc/hostname)_$(date '+%y-%m-%d').tar.gz \
--exclude=/$(cat /etc/hostname)_$(date '+%y-%m-%d').tar.gz \
--exclude=/proc \
--exclude=/tmp \
--exclude=/mnt \
--exclude=/dev \
--exclude=/sys \
--exclude=/run \
--exclude=/media \
--exclude=/var/cache/apt/archives \
--exclude=/usr/src/linux-headers* \
--exclude=/home/*/.gvfs \
--exclude=/home/*/.cache \
--exclude=/home/*/.local/share/Trash \
--exclude=/var/lib/docker /