Welcome!

Please read this important information about Spectre and Meltdown vulnerabilities.
Please read this important information about MX sources lists.

News
  • MX Linux on social media: here
  • Mepis support still here
Current releases
  • MX-17.1 Final release info here
  • antiX-17 release info here
New users
  • Please read this first, and don't forget to add system and hardware information to posts!
  • Read Forum Rules

MX Linux Backup and Restore your running system

Topics relating to MX Docs and MX Videos
Message
Author
User avatar
asinoro
Forum Regular
Forum Regular
Posts: 494
Joined: Mon Feb 22, 2016 12:26 pm

MX Linux Backup and Restore your running system

#1 Postby asinoro » Wed Aug 30, 2017 6:20 am

This guide might look long, but in reality there are 3 commands at Method C who do the job.
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'

To start:

Code: Select all

nmcli con up id 'Wired connection 1'

For WiFi you change:
To stop:

Code: Select all

nmcli radio wifi off

To start:

Code: Select all

nmcli radio wifi on


Run the the modified command of yours for the rsync and pc command separated by semicolon (;) :

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'

Where for rsync:
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


Step 3
If your restore kernel from the backup then run:

Code: Select all

sudo update-grub


Step 4
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


Find your OS and replace the command with yours, where sdxx your partition, to automatically repair the filesystem:

Code: Select all

sudo fsck -a /dev/sdxx

or

Code: Select all

sudo fsck -y /dev/sdxx


Reboot and you will access your OS.

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


And after replace and run the command to fit with yours:

Code: Select all

sudo su

Then

Code: Select all

rm -r /media/xxxx/rootMX161/* ; cp -uvaxT  /xxxx/xxxx/PCBACKUP/  /media/xxxx/rootMX161/ 


To be sure that everything is ok run the command fsck as it is at Step 4.

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'


References
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.
Last edited by asinoro on Tue Oct 24, 2017 5:03 am, edited 20 times in total.
If your case is solved edit [Solved] to your initial post title to help other users.
Don’t forget to Backup your system
Fix your Grub

User avatar
Adrian
Forum Veteran
Forum Veteran
Posts: 8148
Age: 43
Joined: Wed Jul 12, 2006 1:42 am

Re: MX Linux Backup and Restore your running system

#2 Postby Adrian » Wed Aug 30, 2017 7:05 am

I had good success with rsync, what I like about it it can do incremental updates, I usually do this:

Code: Select all

rsync -av /mnt/sda1/ /mnt/backup

To make sure it deletes the file on target after the update:

Code: Select all

rsync -av --delete-after /mnt/sda1/ /mnt/backup

User avatar
asinoro
Forum Regular
Forum Regular
Posts: 494
Joined: Mon Feb 22, 2016 12:26 pm

Re: MX Linux Backup and Restore your running system

#3 Postby asinoro » Wed Aug 30, 2017 7:45 am

With rsync when is about to backup the main File System you must exclude several other system folders and mount points. It does very well with home folder but not with the File System.
If your case is solved edit [Solved] to your initial post title to help other users.
Don’t forget to Backup your system
Fix your Grub

User avatar
Adrian
Forum Veteran
Forum Veteran
Posts: 8148
Age: 43
Joined: Wed Jul 12, 2006 1:42 am

Re: MX Linux Backup and Restore your running system

#4 Postby Adrian » Wed Aug 30, 2017 9:42 am

That's true, but it depends what you want to use it for and how many mount points you have (you can use -x to copy only the files from one file system, it excludes mount points).

skidoo
Forum Regular
Forum Regular
Posts: 750
Joined: Tue Sep 22, 2015 6:56 pm

Re: MX Linux Backup and Restore your running system

#5 Postby skidoo » Wed Aug 30, 2017 1:59 pm

"With rsync [...] you must exclude several other system folders and mount points."
Same as with your cp proposal, you would do that ahead of time, one time ~~ by drafting a custom commandline containing desired command switches/options.
Also, I believe that exclusion of "several other system folders" is a BestPractice.

No, I would not have full confidence in a "backup" fileset created via cp.
cp considers difference based on date, is blind to any partial/corrupt files, vs rsync which considers checksums.
Another consideration: rsync easily handles differential backups (can remove from destination any items which are now-absent at source)

User avatar
asinoro
Forum Regular
Forum Regular
Posts: 494
Joined: Mon Feb 22, 2016 12:26 pm

Re: MX Linux Backup and Restore your running system

#6 Postby asinoro » Wed Sep 06, 2017 9:43 am

Because the friend of good is better, I improved this guide.
If your case is solved edit [Solved] to your initial post title to help other users.
Don’t forget to Backup your system
Fix your Grub

User avatar
asinoro
Forum Regular
Forum Regular
Posts: 494
Joined: Mon Feb 22, 2016 12:26 pm

Re: MX Linux Backup and Restore your running system

#7 Postby asinoro » Mon Sep 11, 2017 6:32 am

It was upgraded to two commands one for backup and one for restore.
There is one gui for dd if we can modify with the commands of backup and restore will be a very nice gui backup and restore for MX Linux!

https://launchpad.net/gdiskdump
If your case is solved edit [Solved] to your initial post title to help other users.
Don’t forget to Backup your system
Fix your Grub

User avatar
penguin
Forum Regular
Forum Regular
Posts: 199
Joined: Wed Jan 04, 2017 3:15 pm

Re: MX Linux Backup and Restore your running system

#8 Postby penguin » Wed Sep 13, 2017 3:44 am

Code: Select all

https://forum.mxlinux.org/viewtopic.php?f=104&t=41293&start=10#p419243

It is a simple method I used to transport a running MX Linux to another drive.
More info for rsync you van find here :

Code: Select all

https://wiki.archlinux.org/index.php/Rsync#As_a_backup_utility

And probably the the simplest way to backup/restore your MX Linux Backup is qt4-fsarchiver utility.I never tried this utility on a running MX Linux.So; I suggest: Start your computer with an bootable MX Linux usb and use qt4-fsarchiver to or restore backup your Mx Linux to/from somewhere.
Hope it helps.

User avatar
Adrian
Forum Veteran
Forum Veteran
Posts: 8148
Age: 43
Joined: Wed Jul 12, 2006 1:42 am

Re: MX Linux Backup and Restore your running system

#9 Postby Adrian » Wed Sep 13, 2017 9:28 am

Also there's Clonezilla if you want to clone the entire drive or a partition, you can install it in MX, it can be used to clone Windows and Linux partitions.

User avatar
asinoro
Forum Regular
Forum Regular
Posts: 494
Joined: Mon Feb 22, 2016 12:26 pm

Re: MX Linux Backup and Restore your running system

#10 Postby asinoro » Wed Sep 13, 2017 10:39 am

The guide of the backup took its final shape! Additionally to restore from a live medium or other Linux OS.
If your case is solved edit [Solved] to your initial post title to help other users.
Don’t forget to Backup your system
Fix your Grub


Return to “Documentation and videos”

Who is online

Users browsing this forum: No registered users and 2 guests