There are several good ways to backup a Linux system, and I'll start with the first one I ever heard of, compression to an archive using tar command.
it's easy to make a tar file of all system and user files with something like
sudu tar {tar options} {location for tar file} {options, excludes} {dir to backup}
Also it's a good idea to exclude $HOME/.cache or clean chromium's or firefox's cache before backup (e.g with bleachbit).
You may want to make the backup on another partition too.
The 'z' option adds gzip to the command so that the tar file is compressed (tar alone just makes one file of everything).
another option is 'u' which updates the tar file, making changes, not sending everything all over again.
Adding the switch --one-file-system will exclude files from other partitions, e.g. for backup of system only:
Using scripts
1. backup system
(name it bkpsys for example)
2. backup home
(name it bkphome for example)
Here's my more precise one:
Using "$HOME" will backup the logged-in user, whereas "/home" will backup all users. Omit "sudo" here so as not to backup the root $HOME!
the resulting tar file will be time-stamped with the day's date.
set up a cron job to run them automatically.
test the tar ball integrity with:
a good archive will give no errors
Update option
If you leave out the date-time parameter so that the file name is the same with each run of the script, and you add the update option 'u', then you'll be able to keep a copy of the system in a tar archive, and just keep updating it. After that you compress it and rename it with the time stamp.
Note that tar will append files to the archive, not replace them inline. So it's probably better to create a new archive each time.
Restoring the system from the backup tar file
WARNING ! this command will overwrite every file on specified target with the files from the backup tar file!
in a Live CD environment (or another running system) copy the tgz archives to a partition (e.g. sda1)
make the system partition (e.g. sda5), home (e.g. sda6) and swap (if there's no other Linux system installed)
Then update GRUB to include the new system
Note: if restoring to a different machine, you'd need to amend the fstab file, so that the system finds its disks, and chroot into the system and run update-grub (or use Boot restore disk).
Rsync
Using this command could be very useful, as it has an update option, -u, which means that you can run it frequently and subsequent runs will send less data to the target file system than the initial sync. It won't compress though, but you just need to afford some space for the backup.
Partclone
Use this to image any disk, and restore the image to another box. You need to use this tool from a live CD (e.g. gparted or your own with partclone installed).
and here https://wiki.archlinux.org/index.php/Partclone
to clone a partition with compression:
to restore the image to a partition (with great care!):
As this tool images whole partitions, without any excludes, you better tidy up the disk especially in user home.
Note: the image can only be restored to a partition equal or larger than the source partition. I tried the option -C to skip checking part space (used if we know that all the data could fit) but the result was a fail.
select type of image dest - local-dev for a disk or USB device
select disk (to mount on CZ's /home/partimag/)
select dir of image
select beginner/expert
select savedisk/saveparts
enter image name
select source (disk/parts) to image
check and run
Restore an Image
Go through like above, select image location as before
select restoredisk/restoreparts
select image to use
select the target disk/parts
check and run
Note: restoring an image from e.g. a 20Gb hdd source onto a 50Gb target, might render the target as a 20Gb disk - gparted will be needed in that case to expand the part to fill the 50Gb.
Make a Live USB
Clonezilla can make a Live CD iso of your cloned image, see here
you need an image already
go through the steps above to restore an image, but after select beginner,
select recovery-iso-zip
select image
select target for restoring from the iso! - change to "ask_user"
select lang, keymap
select iso or zip
Burn the USB
try unetbootin or tuxboot with iso file
or use the zip file with a command like:
and make it bootable with:
RefractaSnapshot
With this script written by fsmithred, you can make a full system backup of your working box, which also becomes a Live Debian that can run or install anywhere you like. It's smooth and easy to use. Runs via CLI or by its GUI.
download refractasnapshot and refractainstaller (base deb and gui deb if needed) from http://sourceforge.net/
cd to download dir
If there are unmet dependencies, sort it out with
for a new system I found refractasnapshot-base needed
squashfs-tools live-boot live-config live-boot-initramfs-tools live-config-sysvinit
version 9.3.3 needed the following...
libburn4 libjte1 libisofs6 libisoburn1 xorriso isolinux
refractainstaller needed grub-pc grub-legacy
Also, you must install a newer version yad (>21.0), necessary for the snapshot installer to run properly, from here sourceforge.net/projects/yad-dialog
change the refracta working directory out of /home (to another partition), using the config file:
edit the exclude list (to reduce the final iso size)
sudo geany /usr/lib/refractasnapshot/snapshot_exclude.list
I added
1b. Post-scripts
these run after the install and before the unmount and reboot.
This one is in process, a script to ask whether a root dir should be moved to another partition - such as /var, or /usr.
check it here https://gist.github.com/fsmithred/...
-it needs to go in /usr/lib/refractainstaller/post-install/
-the source (dir to move) and dest (partition) can be added to the script or you can try using yad to ask for which dir to move (I haven't had time yet to test it)
and
2. Disk clean up
I recommend running Bleachbit as root to clean up the system before running a snapshot back-up.
install the dependencies
This allows install of a Live system to USB from a Live CD iso or from a running live session, and can also update the file-system on USB stick later with a newer one. (Unetbootin can be used if preferred)
http://distro.ibiblio.org/refracta/...
refracta2usb complains if the usb is mounted (and Unetbootin complains if its not mounted!)
Don't eject the device, unmount with pumount /dev/sdb1 etc
Tip: before updating the ISO image on the USB stick, first erase the previous files. It can happen that the stick gets full.
If you can't boot with the stick, try to reformat the USB stick, as a partition mess-up will prevent it booting.
5. refractainstaller
It's a pretty straight forward affair once you boot into your Live system from the USB stick. I get my partitions ready before hand with gparted from Live.
Just run `refractainstaller` or `refractainstaller-yad`to run the installer.
It's very nice to see your snapshot system getting cloned onto another box!
Note: installing on Uefi firmware PCs is not the same as installing on the usual BIOS PC. You need to get refractainstaller 9.2 or later and to install your ISO run `refractainstaller-uefi`...see "uefi and the installer"
Uefi will only boot a 64bit ISO as well - so to install a 32bit Debian, you'll need at least one 64bit ISO on the usb stick in order to boot it and reach the boot menu...
Also, you may need these .deb packages on the root or in home of the ISO, to run a dpkg install using chroot during the refractainstaller process,
You could install these on your 64bit Debian before running the snapshot, but it removes grub-pc, so you should only do that if your Pc is uefi.