# - bof - # :1 # - - # # - Using tar - # :a # - - # # - Create backup folder - # mkdir -p /home/Data2/Images/Backup/; sudo mkdir -p /home/Data2/Images/Backup/uServer/uServer_2021-12-12_Tar/; :b # - - # # - Backup - # TarFile='/home/Data2/Images/Backup/uServer/uServer_2021-12-12_Tar/uServer_'$(date +%Y-%m-%d)'_'$(date +%T)'.tar.gz' FilesToExclude='/dev,/home/Data2/Images/Backup/uServer/*,/home/*/.gvfs,/home/*/.cache,/home/*/.local/share/Trash,/mnt,/media/*,/proc/*,/run/*,/swap.img,/sys,/tmp,/var/cache/apt/archives' sudo tar -cvpzf $TarFile --exclude={$TarFile,/swap.img} --one-file-system / # Just the system alone, no mount partitions sudo tar -cvpzf $TarFile --exclude={$TarFile,$FilesToExclude} / # Everything, but you have to exclude more sudo tar -cvpzf $TarFile --exclude={$TarFile, \ /dev, \ /home/Data2/Images/Backup/uServer/*, \ /home/*/.gvfs, \ /home/*/.cache, \ /home/*/.local/share/Trash, \ /mnt/*, \ /media/*, \ /proc/*, \ /run/*, \ /swap.img, \ /sys/*, \ /tmp/*, \ /var/cache/apt/archives } / # Everything, but you have to exclude more /proc & /sys are virtual filesystems /dev is a tmpfs whose contents are created and deleted dynamically by udev /run is a tmpfs that holds variables about the running system that do not need backed up :b.1 # - - # # - Backup sample - # sudo tar -cvpzf /path/to/backup/yourbackupfilename.tar.gz --exclude=/path/to/backup/yourbackupfilename.tar.gz --one-file-system / --exclude = if backup is in the same partition / = Backup entire root directory :c # - - # # - Restore - # sudo tar -xvpzf /path/to/yourbackupfilename.tar.gz -C /directory/to/restore/to --numeric-owner If restoring complete root directory / :2 # - - # # - Using rzync - # :a # - - # # - Create backup folder - # mkdir -p /home/Data2/Images/Backup/; sudo mkdir -p /home/Data2/Images/Backup/uServer/uServer_2021-12-12_Rsync/; :b # - - # # - Backup - # sudo rsync -aAXv --delete --exclude={/tmp/*,/run/*,/mnt/*,/lost+found,/home/Data2/*,/home/is_derayo/.cache/*} / /home/Data2/Images/Backup/uServer/uServer_2021-12-12_Rsync :b.1 # - - # # - Backup sample - # sudo rsync -aAXv --delete --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/home/*,/lost+found} /source /destination :c # - - # # - Restore - # sudo rsync -aAXv --delete /backup /system # - eof - #