1- One to backup Step 1.
2- One to restored Step 2.
3- One to restore from live medium or other Linux operating system Step 5.
And the Automatic Backup at Step 6
Method A
The best backup is to have a stored image:
https://mxlinux.org/make-snapshot-installed-system
Method B
Or to clone the entire partition of you system:
https://mxlinux.org/forum/viewtopic.php?t=39567
Method C
Another option after trying many different ways with rsync, I decided that the best way to backup and restore the running system can be achieved with the cp command together with the help of the rsync.
The cp command as root copies all the data and places at the storage but do not replaces the old stored data.
This limitation will be corrected with the use of rsync, where the rsync will delete all the data at the storage that do not exist in the source.
The same will be with the restore where it will be deleted everything that doesn’t belong at the backup so, your system will be exactly how it is at the backup.
Always a successful backup it can be, by minimizing the activities of the running system. When you see to be dropped the network stop any activity from your side and leave the program to do its job
Step 1
Backup System
In this example as network is taken eth0 where the commands are.
To stop:
Code: Select all
nmcli con down id 'Wired connection 1'
Code: Select all
nmcli con up id 'Wired connection 1'
To stop:
Code: Select all
nmcli radio wifi off
Code: Select all
nmcli radio wifi on
Code: Select all
sudo nmcli con down id 'Wired connection 1' ; rsync -axv --progress --stats --update --delete-before --ignore-errors --exclude={/dev/*,/proc/*,/sys/*,/var/tmp/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found/*,/.gvfs/*,} / /media/xxxx/xxxx/PCBACKUP/ ; cp -uvaxT / /media/xxxx/xxxx/PCBACKUP/ ; nmcli con up id 'Wired connection 1'
rsync is the command.
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X).
-x, --one-file-system don't cross filesystem boundaries.
-v, --verbose increase verbosity.
--progress show progress during transfer
--stats give some file-transfer stats
--update skip files that are newer on the receiver
--delete-before receiver deletes before transfer, not during
--ignore-errors delete even if there are I/O errors
--exclude= All the folders that can interfere with the system backup.
Where for cp:
cp is the command.
-u, --update copy only when the SOURCE file is newer.
-v, --verbose explain what is being done.
-a, --archive --preserve=all.
-x, --one-file-system stay on this file system.
-T, --no-target-directory treat DEST as a normal file.
The (/) root is the File System.
/media/xxxx/xxxx/PCBACKUP, the stored folder, you choose your own.
The first backup will take time according your stored data on your system, next ones will be more fast thanks to --update, -u option.
Step 2
System Restore
Attention! Before your restore the backup close all running programs.
Run the follow command after modified according your data and change it, if it is for eth0 or WIFI:
Because there is a type of bug the command is modified to delete first the dpkg folder and /var/log/ of the system. Also after the restore updates the database.
Code: Select all
sudo nmcli con down id 'Wired connection 1' ; rm -r /var/lib/dpkg/ ; rm -r /var/log/ ; rsync -axv --progress --stats --update --delete-before --ignore-errors --exclude={/dev/*,/proc/*,/sys/*,/var/tmp/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found/*,/.gvfs/*,} /media/xxxx/xxxx/PCBACKUP/ / ; cp -uvaxT /media/xxxx/xxxx/PCBACKUP/ / ; nmcli con up id 'Wired connection 1'; updatedb
If your restore kernel from the backup then run:
Code: Select all
sudo update-grub
There is one issue which appears often after the restore of kernel. When you boot maybe will not load the OS and it will appear a message with “initramfs”.
Don't worry! From live, DVD, USB, or other Linux OS, open the terminal.
Code: Select all
sudo blkid
Code: Select all
sudo fsck -a /dev/sdxx
Code: Select all
sudo fsck -y /dev/sdxx
Step 5
System Restore from Live Medium or other Linux OS
Because of the live restore, there is the possibility something to go wrong during the restoration of the backup, then the only option is, to have exactly the data of the backup into your system.
To do that, you have to be at live DVD, USB or another Linux OS and to run the following commands:
First it removes all the data from your System Folder with ( rm -r ) in this example the name is rootMX161, which is the default during installation.
Then you run the pc command from storage backup, where it is here the PCBACKUP, to your system folder where again here it is rootMX161. Of course you will change the names with yours.
Run the command, to find your OS, where now it is rootMX161:
Code: Select all
sudo blkid
Code: Select all
sudo su
Code: Select all
rm -r /media/xxxx/rootMX161/* ; cp -uvaxT /xxxx/xxxx/PCBACKUP/ /media/xxxx/rootMX161/
Step 6
Automatic Backup
This is the manual way, what nicer the automatic backup, for that you can follow the tutorial as how to use gnome-schedule which is already installed at MX 16:
https://mxlinux.org/forum/viewtopic.php?t=39567
Where as a command you will use the modified of yours:
Code: Select all
nmcli con down id 'Wired connection 1' ; rsync -ax --progress --stats --update --delete-before --ignore-errors --exclude={/dev/*,/proc/*,/sys/*,/var/tmp/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found/*,/.gvfs/*,} / /media/xxxx/xxxx/PCBACKUP/ ; cp -uvaxT / /media/xxxx/xxxx/PCBACKUP/ ; nmcli con up id 'Wired connection 1'
1- With this system backup it combines the flexibility of rsync with the stability of the coreutil cp.
2- It can run a backup from a running system minimizing the possibilities to go wrong, by stopping and restarting network. This option it can be deactivated with private risk.
3- There is not limitation of the stored data.
4- The stored data are secure because the folder is made by the root and are visible and accessible from the user.
5- The time of the backup except the first one will be fast thanks to the options –update and -u of the commands.
6- It will restore the live system fast, and more reliable from a live medium or other Linux OS.
7- With the gnome-schedule it can do automatic several different backups, I suggest one in a step of 15 days and another one, daily. Two automatic backups are better than one.
8- This backup keeps all the information of your system, partitions, grub, etc, where when your restore it from a live medium or another Linux OS, your system will be exactly how it was the time of the backup.
9- The quality of the backup it is equal to dd, because cp it is also coreutil, the difference it is that stores only the data and not all the sectors of the partition.
10- Nothing is perfect any suggestions that improves is always welcome, and because nothing is more important in the computer world than our operating system.
Enjoy the Linux flexibility and simplicity.