MX-15/16.1 Linux Tutorial How to Automatic Clone Backup and Restore System

Topics relating to MX Docs and MX Videos
Post Reply
Message
Author
asinoro
Posts: 152
Joined: Mon Feb 22, 2016 12:26 pm

MX-15/16.1 Linux Tutorial How to Automatic Clone Backup and Restore System

#1 Post by asinoro »

MX-15 Linux Tutorial How to Automatic Clone Backup System and Restore

Clone system backup is the perfect way to store and restore your operating system without to loose data and applications that it took you so long time and effort to achieve. Additionally very fast you can restore your operating system and bring back exactly how it was .You can store your operating system on another partition, hard drive or preferably to external medium. The best way is to store in an img.gz format to avoid luck of space and size.
For example my operating system installed on almost 30 gigabyte size partition with 9GB space occupied, it can be stored as an image.gz format to a file taking 6.8 gigabyte size in about 28 minutes.
To restore it takes about 18 minutes in my laptop with dual core processor. Time is always according the pc and the store medium speed abilities.
The ideal way to clone system backup is to be automatic, perfect way if you do not have time or forget this important work of your operating system. The backup will be automatically with the application gnome-schedule, using the commands dd and gzip.
The gnome-schedule is a great tool with many programming options. In this guide you will see the more advanced root operation.
In this tutorial home and root are together because configuration files are on home folder and are very important for the reliable function of the applications and root is your operating system. For me a compact system is the best.
Pay attention Cloning system backup will take place within your operating system for that reason not to run applications that disturb the operation. Browsing and listening music from my experience will not causing issues, but the best is not even to have network activities.

Step 1

First to check from Terminal if the cron job operates and it is active.

Code: Select all

service cron status
If this indicator comes is active.
[ ok ] cron is running.
If not then you start the application.

Code: Select all

sudo service cron start
Re-Enter the superuser root password to reconnect root with cron again.

Code: Select all

sudo passwd root
Step 2

Install the gnome-schedule.

Code: Select all

sudo apt-get install gnome-schedule 
After installation from the Terminal.

Code: Select all

sudo gnome-schedule
Step 3

Once you start the gnome-schedule, go on the left will select New> A task that launches recurrently or Recurrent task.

Image

Step 4

Here you will customize the program.

Description: Give a name to work (I gave MX-15xfce).
Default behaviour: Leave as it is.
Command: The most important part pay attention.

Image
Image

The following command you will customize according to your settings, and it would be good to save and modify in LibreOffice Culc.

Code: Select all

sudo service network-manager stop && DISPLAY=:0.0 sudo -u panpan /usr/bin/notify-send "Start Cloning system" && dd if=/dev/sda9 bs=4096 conv=notrunc,noerror | gzip> /media/LAPTOPSTORE/Lenovo5030/MX15xfce.img.gz && DISPLAY=:0.0 sudo -u panpan /usr/bin/notify-send "Completed Cloning System" && sudo service network-manager restart
/media/LAPTOPSTORE/Lenovo5030/MX15xfce.img.gz
Pay attention to the bold letters not to have any space between them otherwise the command will not work.

As you notice the code has sudo service network-manager stop and sudo service network-manager restart. If you want to have a good backup you must not interact with you system direct or indirect, which means not any activity by you or the Internet.
If those commands do not work for you can skip them.
sudo service network-manager stop &&
&& sudo service network-manager restart
Next

1) Change to your own user name panpan is mine.
2) Instead sda9 which is my own partition of my operating system, the corresponding yours. You can find yours by sudo blkid or by opening gparted.
3) Made the destination backup folder on a different sector (partition) of the hard drive or an external storage. After making that folder right click that folder copy and paste to replace part of my own example [/ media /LAPTOPSTORE/Lenovo5030], with the corresponding yours.
After you add the name of the image that you want to give [xxxxxxx.img.gz]. So your command will look like this.

Code: Select all

sudo service network-manager stop && DISPLAY=:0.0 sudo -u username /usr/bin/notify-send "Start Cloning system" && dd if=/dev/sda9 bs=4096 conv=notrunc,noerror | gzip> /media/xxxxxx/xxxxxxx/xxxxxxx.img.gz && DISPLAY =:0.0 sudo -u username /usr/bin/notify-send "Completed Cloning System" && sudo service network-manager restart
If it is ready your command now copy and paste into the field Command:

Step 5

The following settings you can modify to suit your needs, I show what settings I have chosen.

Select the Field Advanced >
1) Month > Edit > Every month > OK. Every month to run the task.
2) Day > Edit > In a step width - Days 7 > OK. To perform the task every 7 days of the month. A good setting for something that went wrong recently.
3) Hour > Edit > At an exact hour- Hour 11 > OK. To run on 11 or your own time selection.
4) Minute 0

Pay attention do not select the Edit option (in a range, it will do the job every, minute, hour and so on.

When you complete the settings you select Add > OK and ready your backup order for automatic image storage.

Image


Step 6

Now some things to keep in mind. The backup will be automatically and if you don't change the name MX15xfce.img.gz, then it remains the same file and every time that does the backup, it will be replaced again and again. Only you will know that it is the latest version of image backup. If you have space at your store and want to save more images, then you change the file name at the backup storage from MX15xfce.img.gz, to MX15xfce1.img.gz after the first storage. The same way you can store more images.
To see when the cloning backup starts and stops follow this post.
viewtopic.php?f=108&t=39554&hilit=recen ... 20#p381375
If you want to do the cloning backup manual:
From the program you can select the task > Then above - run selected task - > Execute
or
modify the command according your settings:
dd if=/dev/sda9 bs=4096 conv=notrunc,noerror | gzip> /media/LAPTOPSTORE/Lenovo5030/MX15xfce.img.gz
then
sudo su
and run the command at the terminal
Step 7

Restore your cloning saved backup to your system

Always restore takes place outside the operating system from Live DVD, USB or other functional Linux operating system.

From the Terminal first the command.

Code: Select all

sudo su
and then.

Code: Select all

gzip -dc /media/LAPTOPSTORE/Lenovo5030/MX15xfce.img.gz | dd of =/dev/sdax bs=4096 conv=notrunc,noerror
To restore the backup image you will copy the saved image with your right mouse button and paste to replace [/ media/LAPTOPSTORE/Lenovo5030/MX15xfce.img.gz] in LibreOffice Culc. Your command will be then ready with the right form of the stored image. Change also the /dev/sdax where the ax the hard drive and partition of your target operating system.
If you have correctly made the restore command, in LibreOffice Culc, next time you use the same by copying and pasting.

During the operation open another terminal give the following command to see the procedure of the work from the first terminal.

Code: Select all

watch -n5 'sudo kill -USR1 $ (pgrep ^ dd)'
Restore time will be according file size of your OS and according the pc and the store medium speed abilities.

Enjoy this important automatic operation.
Last edited by asinoro on Wed Aug 30, 2017 6:28 am, edited 7 times in total.
If your case is solved, edit [Solved] to your initial post title to help other users.

Fix your Grub

dyfi
Posts: 28
Joined: Sat Jan 01, 2011 10:13 am

Re: Tutorial Linux MX-15 How to Automatic Clone Backup Syste

#2 Post by dyfi »

Nicely explained, but not sure about using dd on a running system. It will work, but could easily create a corrupt image if anything is written to disk during the operation, as you have illustrated. I use fsarchiver as a daily cron job on a running system. This creates a reliable file system archive (like tar) whereas dd is at the partition level.

That said, at least you are aware of the importance of backing up and whatever method suits one person may not be ideal for another.

User avatar
Jerry3904
Administrator
Posts: 21881
Joined: Wed Jul 19, 2006 6:13 am

Re: Tutorial Linux MX-15 How to Automatic Clone Backup Syste

#3 Post by Jerry3904 »

I appreciate the work you put into this! We don't have much documentation like this on specific applications, so after some review here we can put it into the Wiki's Applications section.

BTW: gnome-schedule is installed by default in MX-15, showing up as "Scheduled Tasks" in the menu.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

asinoro
Posts: 152
Joined: Mon Feb 22, 2016 12:26 pm

Re: Tutorial Linux MX-15 How to Automatic Clone Backup Syste

#4 Post by asinoro »

I have tried this method more than 30 times backup and restore mostly manual and also automatic. They where some issues with active network connection during the backup with Ubuntu and Linux Mint but never with network disconnected. I don't know why thats why as I explain the best it is with not network activities.
With manual way everything is under control the same with sudo service network-manager stop in automatic way if it works with your system.
If your case is solved, edit [Solved] to your initial post title to help other users.

Fix your Grub

asinoro
Posts: 152
Joined: Mon Feb 22, 2016 12:26 pm

Re: Tutorial Linux MX-15 How to Automatic Clone Backup Syste

#5 Post by asinoro »

Jerry3904 wrote:I appreciate the work you put into this! We don't have much documentation like this on specific applications, so after some review here we can put it into the Wiki's Applications section.

BTW: gnome-schedule is installed by default in MX-15, showing up as "Scheduled Tasks" in the menu.
To see gnome-schedule as a root and the cron jobs then needs sudo gnome-schedule
If your case is solved, edit [Solved] to your initial post title to help other users.

Fix your Grub

User avatar
Jerry3904
Administrator
Posts: 21881
Joined: Wed Jul 19, 2006 6:13 am

Re: Tutorial Linux MX-15 How to Automatic Clone Backup Syste

#6 Post by Jerry3904 »

I was referring to the "install" step.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

dyfi
Posts: 28
Joined: Sat Jan 01, 2011 10:13 am

Re: MX-15/16.1 Linux Tutorial How to Automatic Clone Backup and Restore System

#7 Post by dyfi »

I'm posting again on this topic after a long period of time. I've always been very wary of dd'ing a running system, since the image taken is at the block level and not the file level and so file errors can occur if the disk is written to.

Just when you think your linux wisdom is pretty good you can still pick up the extra tip. I've recently discovered the "fsfreeze" command. Only has two options, -f for file-system freeze and -u to unfreeze. The terminal will still work if already open. Basciacally freezes your / whilst a backup is performed (from a terminal), and then use -u option to unfreeze and continue working. Similar to mounting a root system as read only for a short while. This makes dd'ing much safer IMO.

Post Reply

Return to “Documentation and videos”