Skip to content

Instantly share code, notes, and snippets.

@bootrino
Created June 7, 2023 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bootrino/bc4a4b8bfe82180391904046c2c9e344 to your computer and use it in GitHub Desktop.
Save bootrino/bc4a4b8bfe82180391904046c2c9e344 to your computer and use it in GitHub Desktop.
backup a linux machine with xz compression using all CPU cores
# compression level 9, use all cores
XZ_OPT='-T$(nproc) -9'
# J means xz compression, z means gz
NUM_THREADS=$(nproc)
sudo env "XZ_OPT=-T${NUM_THREADS} -7" tar -cvpJf /tmp/backup.tar.xz \
--exclude=/tmp/backup.tar.xz \
--exclude=/var/swap.1 \
--exclude=/proc \
--exclude=/mnt \
--exclude=/dev \
--exclude=/sys \
--exclude=/run \
--exclude=/media \
--exclude=/boot \
--exclude=/usr/src/linux-headers* \
--exclude=/home/*/.gvfs \
--exclude=/home/*/.cache \
--exclude=/home/*/.local/share/Trash \
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment