LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-27-2015, 09:51 AM   #1
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Rep: Reputation: Disabled
What is the best way to back up a system?


Hi. I need to shut down a linux virtual machine on a remote server. The virtual machine will be deleted thereafter. But before I do, I would like to make an (iso) image of the entire system and burn it onto a DVD or ftp it to another machine. Can anyone tell me how to make the iso image Thanks
 
Old 06-27-2015, 10:06 AM   #2
Head_on_a_Stick
Senior Member
 
Registered: Dec 2014
Location: London, England
Distribution: Arch & Debian
Posts: 1,183

Rep: Reputation: 284Reputation: 284Reputation: 284
If it is a Debian-based system, have a look at Refracta and their "refractasnapshot" & "refracta2usb" tools.
http://www.ibiblio.org/refracta/
 
Old 06-27-2015, 10:59 AM   #3
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Yes, I am running Ubuntu 12.04.5. However, I need to run everything from the command prompt.
 
Old 06-27-2015, 11:20 AM   #4
fatmac
Senior Member
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: AntiX
Posts: 1,950

Rep: Reputation: Disabled
Use genisoimage to create your .iso & growisofs to burn it to DVD disc.
 
1 members found this post helpful.
Old 06-27-2015, 03:28 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 17,101

Rep: Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552
Why do you want to make an iso??

Just copy off the virtual hard drive file and associated files.
 
Old 06-27-2015, 04:03 PM   #6
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Ya, long story. Copying the VD is the easiest, but we need to send my host an encrypted HD for security reasons to store it, and that will take too long. Plus, their VD export is windows based, which is useless to us. So, I thought I would just remotely pack up the entire system and reinstall as an ISO at a later point.

I thought I could also just make a tar of the entire system. But when I am ready to recreate the system, an initial system would still be needed to be installed, and I didn't know if untar'ing the pre-existing system in it would overwrite the newer system and what other problems there would be (like updating grub). So, I thought the ISO solution would be better.
 
Old 06-28-2015, 02:49 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,951

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
Quote:
Originally Posted by tearsforhari View Post
So, I thought I would just remotely pack up the entire system and reinstall as an ISO at a later point.

I thought I could also just make a tar of the entire system. But when I am ready to recreate the system, an initial system would still be needed to be installed, and I didn't know if untar'ing the pre-existing system in it would overwrite the newer system and what other problems there would be (like updating grub). So, I thought the ISO solution would be better.
And why would an iso burnt to a CD/DVD be any different ?.
There is no need to have an already installed system - just use a liveCD/USB to recover your system. But there will still be post-recovery work to do - grub, initrd, driver loading maybe. A lot will depend on the hardware at the other end.
FWIW I like to use fsarchiver - CRC checks the data, and is just a file you can ship any way you want - I just migrated this laptop onto a new harddisk using it. Piece of cake.
 
Old 06-28-2015, 03:20 AM   #8
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
The ISO would not be burnt onto a DVD. I doubt with the MySQL data on it that it would fit onto one. The ISO would rather be transferred to another server, which would be available for download remotely for the host to reinstall it later down the line. When they create a new VM on their Windows environment, the ISO should just install the system as it was without post recovery work, I am assuming.

So far, genisoimage might answer my question. But I am open to additional comments.
 
Old 06-28-2015, 04:01 AM   #9
scdbackup
Member
 
Registered: Oct 2013
Posts: 53

Rep: Reputation: Disabled
Hi,

i read the intention to make a bootable ISO for backup.
This would imply to have an operating system on it plus a boot loader (GRUB2, ISOLINUX) plus the necessary entry points for firmware (El Torito, MBR, GPT). It is questionable whether you can make the operating system on virtual hard disk boot from ISO. At least it will be expert work.
(I could help with ISO, El Torito, MBR, GPT, but not with operating system boot stages.)

And then you want to install your backuped OS onto a virgin disk. So you do not only need a ISO bootable OS but also installer software which can exploit the backuped files. This would be a big software project, i guess.

You could try to make a flat device copy of the hard disk (e.g. dd if=/dev/sda of=...pipe.out...) from within the running operating system on the virtual machine. This would give you at best a disk state like after a sudden power off. Additionally there may be inconsistencies of the file system because it is not backuped in a single snapshot while the system is running on it.
As with traditional backup of a running system, there may occur inconsistencies of file content and attributes between files which get coordinated by running software (e.g. data base files).
So sync before backup and stop as much disk activity as possible. Expect the need for filesystem repair and a thorough test of restored system for subtle damages. Have a traditional backup ready, too, for fixing larger mishaps.

Better would be to boot to rescue mode or to boot an OS from a different device. Then you could make an image of the properly unmounted virtual disk.

Such a device image should be usable with a local virtual machine or with a real machine which are compatible with the remote virtual machine.

Else you probably have to settle with the idea to first install a new operating system and to then pick what is missing from a traditionally backuped directory tree. (Like with flat dd, one should reduce disk activity in order to get as few inconsistent file states as possible.)

Have a nice day

Thomas
 
Old 06-28-2015, 04:34 PM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,711

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
Don't use genisoimage - The resulting file could not be properly restored as most/all the metadata (ownership, access modes, acls...) will be discarded.

You should be able to boot to single user mode without a root (if nothing else use "init=/bin/bash", then use the tools on the initrd to restore your system. I believe the initrd include (at a minimum) cpio, and tar - but you can look to see which, then use that to make your backup.
 
Old 06-28-2015, 08:37 PM   #11
androidguy555
LQ Newbie
 
Registered: Jun 2015
Posts: 8

Rep: Reputation: Disabled
I've once used the Export Appliance feature within virtualbox to make a backup of my virtual guest and then used the Import Appliance to restore it and everything was fine. The virtual appliance will have a .ova extension. You can also encrypt the .ova file using gpg, openssl, ccrypt or other command.

@ tearsforhari
Since you said, the usage of the export appliance is not suited for your needs, and you need an alternative. I do have a couple of suggestions:


If you had used LVM, you could have created snapshot(s) of each logical volume and then backup the mounted snapshots with tar or rar.

Another alternative is to rsync your '/' directory to a secondary partition on your virtual guest, to a directory on your host machine or to your online server.
 
Old 06-29-2015, 03:46 PM   #12
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
Oh boy! Ok, I did the following instead:

I am running Ubuntu 12.05.4. I used the following command to make a backup of my system running as a VM on a server:

>tar -cvpf /backups/fullbackup.tar --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups .

1. Now, I wish check whether the tar worked by restoring it to a subdirectory. Is this possible? If so, what is the command. "tar -xvf" doesn't seem to work.

2. What is involved when I restore my system?
 
Old 06-29-2015, 04:34 PM   #13
androidguy555
LQ Newbie
 
Registered: Jun 2015
Posts: 8

Rep: Reputation: Disabled
tar -xvf inputfile.tar -C /path/to/test/directory/

You did use the correct switches '-xvf' to extract a tarball. It's mystery why it didn't work.

Can you provide the exact error message you got after executing the command?

Last edited by androidguy555; 06-29-2015 at 04:39 PM.
 
Old 06-29-2015, 04:36 PM   #14
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,711

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
You can.

What I do is "cd the_directory; tar -xf /path_to_backup_file".

As long as the backup doesn't include the absolute path (as in starting the names with a "/") this works. You can easily check that with a "tar -vtf /path_to_backup_file" which will list the files (like a "ls -l" does). Not storing the leading "/" is the default for tar.

I've used this to move a system within a VM to a bare metal root filesystem.

The only requirement is to install the boot after restoring the system.
 
Old 06-29-2015, 05:45 PM   #15
tearsforhari
Member
 
Registered: Mar 2015
Posts: 79

Original Poster
Rep: Reputation: Disabled
My bad; I just was too stressed out at the time, thinking that it might overwrite the existing system. The tar xvf worked in a subdirectory.
I assume if I restore in the "/" directory, the tar will overwrite all existing system files. Is this correct? As for restoring, I am wondering if any of the exclude directories would have to be handmade again by mkdir? Do I have to update2-grub before rebooting? Thnks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Back up Debian system to another system?? since1993 Linux - Newbie 1 10-16-2009 03:31 PM
Need to take my system back, and am nervous LovingLinux Linux - Newbie 8 04-17-2009 02:54 AM
Best way to back up system? replica9000 Linux - Software 8 12-17-2007 12:13 PM
How can I back up my system? Jongi Ubuntu 4 04-28-2006 03:14 AM
system back-up powadha Linux - Software 1 12-26-2003 11:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration