PDA

View Full Version : Howto: Backup and restore your system!



Pages : [1] 2 3 4 5 6

Heliode
May 17th, 2005, 08:29 PM
More recent up to date information this tutorial deals with can be found on the Ubuntu Wiki

https://help.ubuntu.com/community/BackupYourSystem
https://help.ubuntu.com/community/BackupYourSystem/TAR
https://help.ubuntu.com/community/CategoryBackupRecovery


Thread closed.


Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!

Most of you have probably used Windows before you started using Ubuntu. During that time you might have needed to backup and restore your system. For Windows you would need proprietary software for which you would have to reboot your machine and boot into a special environment in which you could perform the backing-up/restoring (programs like Norton Ghost).
During that time you might have wondered why it wasn't possible to just add the whole c:\ to a big zip-file. This is impossible because in Windows, there are lots of files you can't copy or overwrite while they are being used, and therefore you needed specialized software to handle this.

Well, I'm here to tell you that those things, just like rebooting (http://www.ubuntuforums.org/showthread.php?t=34629), are Windows CrazyThings (tm). There's no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter). In fact; using Ghost might be a very bad idea if you are using anything but ext2. Ext3, the default Ubuntu partition, is seen by Ghost as a damaged ext2 partition and does a very good job at screwing up your data.

1: Backing-up

"What should I use to backup my system then?" might you ask. Easy; the same thing you use to backup/compress everything else; TAR. Unlike Windows, Linux doesn't restrict root access to anything, so you can just throw every single file on a partition in a TAR file!

To do this, become root with


sudo su

and go to the root of your filesystem (we use this in our example, but you can go anywhere you want your backup to end up, including remote or removable drives.)


cd /


Now, below is the full command I would use to make a backup of my system:



tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

Now, lets explain this a little bit.
The 'tar' part is, obviously, the program we're going to use.

'cvpfz' are the options we give to tar, like 'create archive' (obviously),
'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.

Next, the name the archive is going to get. backup.tgz in our example.

Next comes the root of the directory we want to backup. Since we want to backup everything; /

Now come the directories we want to exclude. We don't want to backup everything since some dirs aren't very useful to include. Also make sure you don't include the file itself, or else you'll get weird results.
You might also not want to include the /mnt folder if you have other partitions mounted there or you'll end up backing those up too. Also make sure you don't have anything mounted in /media (i.e. don't have any cd's or removable media mounted). Either that or exclude /media.

EDIT : kvidell suggests below we also exclude the /dev directory. I have other evidence that says it is very unwise to do so though.

Well, if the command agrees with you, hit enter (or return, whatever) and sit back&relax. This might take a while.

Afterwards you'll have a file called backup.tgz in the root of your filessytem, which is probably pretty large. Now you can burn it to DVD or move it to another machine, whatever you like!

EDIT2:
At the end of the process you might get a message along the lines of 'tar: Error exit delayed from previous errors' or something, but in most cases you can just ignore that.

Alternatively, you can use Bzip2 to compress your backup. This means higher compression but lower speed. If compression is important to you, just substitute
the 'z' in the command with 'j', and give the backup the right extension.
That would make the command look like this:



tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /


2: Restoring

Warning: Please, for goodness sake, be careful here. If you don't understand what you are doing here you might end up overwriting stuff that is important to you, so please take care!

Well, we'll just continue with our example from the previous chapter; the file backup.tgz in the root of the partition.

Once again, make sure you are root and that you and the backup file are in the root of the filesystem.

One of the beautiful things of Linux is that This'll work even on a running system; no need to screw around with boot-cd's or anything. Of course, if you've rendered your system unbootable you might have no choice but to use a live-cd, but the results are the same. You can even remove every single file of a Linux system while it is running with one command. I'm not giving you that command though! ;-)

Well, back on-topic.
This is the command that I would use:



tar xvpfz backup.tgz -C /


Or if you used bz2;



tar xvpfj backup.tar.bz2 -C /


WARNING: this will overwrite every single file on your partition with the one in the archive!

Just hit enter/return/your brother/whatever and watch the fireworks. Again, this might take a while. When it is done, you have a fully restored Ubuntu system! Just make sure that, before you do anything else, you re-create the directories you excluded:


mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
etc...


And when you reboot, everything should be the way it was when you made the backup!

2.1: GRUB restore
Now, if you want to move your system to a new harddisk or if you did something nasty to your GRUB (like, say, install Windows), You'll also need to reinstall GRUB.
There are several very good howto's on how to do that here on this forum, so i'm not going to reinvent the wheel. Instead, take a look here:

http://www.ubuntuforums.org/showthread.php?t=24113&highlight=grub+restore

There are a couple of methods proposed. I personally recommend the second one, posted by remmelt, since that has always worked for me.


Well that's it! I hope it was helpful!
As always, any feedback is appreciated!

Rehevkor
May 17th, 2005, 08:46 PM
Excellent guide :)

I'd like to try this, but I have very limited space on this hard drive (laptop) and I'm pretty certain I don't have room to generate the backup here. Is there a way to redirect the resulting backup.tgz to shared folder on my windows network instead of a local partition? Perhaps by using smbmount to mount the share, then create the backup.tgz from that location?

Heliode
May 17th, 2005, 09:03 PM
Excellent guide :)

I'd like to try this, but I have very limited space on this hard drive (laptop) and I'm pretty certain I don't have room to generate the backup here. Is there a way to redirect the resulting backup.tgz to shared folder on my windows network instead of a local partition? Perhaps by using smbmount to mount the share, then create the backup.tgz from that location?

Exactly! ;) Just make sure you exclude the mounted folder or you'll end up backupping your Windows drive as well! ;)

Sam
May 17th, 2005, 10:12 PM
Exactly! ;) Just make sure you exclude the mounted folder or you'll end up backupping your Windows drive as well! ;)
What about /dev and /sys folders ? They are virtual, so there is no need to archive them.

Heliode
May 17th, 2005, 10:14 PM
O, right, guess that is why you can get errors at the end of the backup process. I guess it doesn't hurt to exclude them, but in my personal experiance it doesn't hurt to include them either! ;)

kvidell
May 17th, 2005, 10:20 PM
O, right, guess that is why you can get errors at the end of the backup process. I guess it doesn't hurt to exclude them, but in my personal experiance it doesn't hurt to include them either! ;)
Theoretically, yes it does.
It'll backup /dev/hda which will end up giving you a how-ever-many gig image of your harddrive.... and if you're backing it up, why do you need that? You already have it.
All it does is double the size of the bcakup file with a useless disk image that's only good for loopback mounting.
- Kev

MetalMusicAddict
May 17th, 2005, 10:36 PM
This is awesome. After I get my Thinkpad in and configured Ill use this to make a backup. Thanx. ;)

Heliode
May 18th, 2005, 09:41 AM
Theoretically, yes it does.
It'll backup /dev/hda which will end up giving you a how-ever-many gig image of your harddrive.... and if you're backing it up, why do you need that? You already have it.
All it does is double the size of the bcakup file with a useless disk image that's only good for loopback mounting.
- Kev


Ok I think you're right. I'll edit the howto.
But if you just recreate the dev directory after restoring, does the system automatically recreate the device nodes?
Somehow I don't think i've ever had the problem you discribe. My backups have always been somewhat proportional to the amount of data that was actually on the disk; I didn't have it suddenly double in size or anything. But if Linux just recreates the device nodes by itself then I guess it is save to exclude 'dev'.

maspro
May 18th, 2005, 03:41 PM
Nice guide.

But I used Norton Ghost which works perfectly for me. Norton Ghost 2003 supports EXT2/EXT3 filesystems. Older versions of Norton Ghost DON'T support EXT3 filesystems or Linux altogether.

Please go to this site (http://service1.symantec.com/SUPPORT/ghost.nsf/docid/1999021909463125?Open&src=&docid=2000033111503625&nsf=ghost.nsf&view=docid&dtype=&prod=&ver=&osv=&osv_lvl=) for a feature compare between the different Norton Ghosts versions: Norton Ghost compatibility with Linux. (http://service1.symantec.com/SUPPORT/ghost.nsf/docid/1999021909463125?Open&src=&docid=2000033111503625&nsf=ghost.nsf&view=docid&dtype=&prod=&ver=&osv=&osv_lvl=)

I ended up with a backup-image that's about 1 GB big, the amount of data on the disk that was backed-up by Norton Ghost was about 2 GB. So as you can see the compression was very good. I went from 2 GB to 1 GB. :grin:

Sam
May 18th, 2005, 03:45 PM
Nice guide.

But I used Norton Ghost which works perfectly for me. Norton Ghost 2003 supports EXT2/EXT3 filesystems. Older versions of Norton Ghost DON'T support EXT3 filesystems or Linux altogether.

Please check go to this site (http://service1.symantec.com/SUPPORT/ghost.nsf/docid/1999021909463125?Open&src=&docid=2000033111503625&nsf=ghost.nsf&view=docid&dtype=&prod=&ver=&osv=&osv_lvl=) for a feature compare between the different Norton Ghosts versions: Norton Ghost compatibility with Linux (http://service1.symantec.com/SUPPORT/ghost.nsf/docid/1999021909463125?Open&src=&docid=2000033111503625&nsf=ghost.nsf&view=docid&dtype=&prod=&ver=&osv=&osv_lvl=)

:)
But it's a commercial application.... :?

maspro
May 18th, 2005, 03:51 PM
But it's a commercial application.... :?
:-# ;-) true, very true.

Heliode
May 18th, 2005, 03:54 PM
But it's a commercial application.... :?

Exactly. And it also requires you to shut down your operating system. This might be fine for your workstation, but not something you'd really want to do with a server.

Also, What if you want to backup to a USB device? Or a firewire device? Or to a machine on your network? Or to a machine somewhere on the internet? All that is possible when you backup from a running operating system and the TAR method.

Sure, ghost might be a great application, but it'll cost you $47.00 at least, which is kind of silly when the rest of the software you are using didn't cost you a penny ;)

My point being: Ghost might be good, but you don't need it

(p.s. the link to the symantec site doesn't really work for me)

maspro
May 18th, 2005, 04:05 PM
Also, What if you want to backup to a USB device? Or a firewire device? Or to a machine on your network? Or to a machine somewhere on the internet? All that is possible when you backup from a running operating system and the TAR method.

Well I backup-up to a USB-flash drive. Since I don't have a floppy-drive in my laptop, but I did have a Norton Ghost floppy, I first copied the contents of the floppy to a CD and made it bootable, then I booted from the CD which ran Norton Ghost and which also recognized my USB-flash drive. I then choose to make a back-up of my Ubuntu EXT3 partition and put it on the USB-flash drive.

About the reboot, yeahh your absolutely right about that one, but the latest versions of Norton Ghost doesn't even need a reboot anymore to back-up Windows. But where talking about Linux here, and since this program doesn't run on Linux..... ;-) .... you get the picture! :)

maspro
May 18th, 2005, 04:20 PM
(p.s. the link to the symantec site doesn't really work for me)
Well, I made a copy past for you from the website: :)

Ghost compatibility with Linux

Situation:
You are preparing to use Ghost to clone a computer that contains the Linux operating system, and you want to know whether your version of Linux has been tested with Ghost.

Solution:
Whether Ghost can clone a drive or a partition from a Linux computer depends on the version of Ghost, the version of Linux, and the type of file system. In general, Ghost versions prior to 6.0 can do only sector-by-sector copies of entire drives. Ghost versions 6.0 and later are compatible with many versions of Linux and can clone both drives and individual partitions.

Supported file systems
All Ghost versions support sector copy operations for Linux disks. Sector copy operations can clone entire disks and not individual partitions.

Ghost versions that support EXT2 or EXT3 can perform a native copy operation, which supports the cloning of individual partitions. Ghost versions that support EXT2 or EXT3 partitions allow all of the same functionality on EXT2 and EXT3 partitions as they do with FAT and NTFS partitions.

Ghost does not support other Linux file systems such as Reiserfs.

http://img271.echo.cx/img271/8648/ghost2oq.jpg

Details regarding specific Ghost versions with specific Linux versions

(1) Both Red Hat 6.1 and Mandrake 6.1 use 4 KB block sizes by default. In some cases, Ghost 6.0 - 6.02 will work successfully on these, but this is not a supported configuration for Ghost 6.0 - 6.02. Ghost 6.03, 6.04, 6.5, 7.0 and 7.5 handle 4 KB block sizes appropriately and are supported in these configurations.

(4) Lockup problems with Mandrake 7.0 in Ghost versions 6.0 - 6.02 might be resolved by using the -ID switch on Ghost.exe. These problems were resolved in 6.03. However, the patching of LILO after cloning with Ghost 6.03 will fail if the default target in /etc/lilo.conf is other than the first target. To prevent this target problem, change the order of the targets in /etc/lilo.conf so that the default target is the first one in the list, then run /sbin/lilo to rewrite the /boot/map file.

(5) Ghost 6.0 - 6.04 might work with Slackware 7.0, provided Slackware 7.0 does not use 4 KB block sizes. However, Ghost 6.0 - 6.04 do not support Slackware 7.0 at this time.

(6) Ghost 6.03, 6.04, 6.5, 7.0 and 7.5 are compatible with Corel Linux 1.0. These Ghost version can handle the "compact" option that Corel Linux uses for LILO. Ghost 6.0 - 6.02 cannot handle the "compact" option that Corel Linux uses for LILO, so the clone will need to be booted from floppy disk after cloning.

(7) Ghost 6.04 and earlier does not work with Linux versions that use Supermount for accessing floppy disks or CDs. Ghost stops responding during computer startup and cannot be loaded into memory. Typical Linux versions that might use Supermount include Mandrake 7.0 and Caldera 2.3. This problem has been fixed in Ghost 6.5.

( 8 ) In testing, the Linux Hotfix to Ghost 6.51 (this hotfix is included in Symantec Ghost 7.0 and later) appears to fix some problems between Ghost and Red Hat 7.1.

Technical Information:
Linux file names
Linux files with file names that are not valid in Windows might not restore correctly using Norton Ghost Explorer. For instance, the file MYFILE.TXT, is a valid Linux file, but it cannot be restored using Norton Ghost Explorer.

Linux Kernel 2.2 with the EXT2 file system
If your Linux version uses the new Linux Kernel 2.2 and you add the extended features to the EXT2 file system, you might have problems with Ghost. Symantec is aware of the problem and is investigating its cause. There is no known solution or workaround at this time. For more information on the extended features of the EXT2 file system , consult your Linux Kernel 2.2 documentation.

Dual booting
Ghost supports dual booting with the Windows operating system and a supported Linux version only in a stand alone configuration. When using Ghost Multicast Server, GhostCast Server, or Ghost Console to work with a client computer, Ghost does not support dual booting on the client computer.

--------------------------------------------------------------------------------
Note: If you have problems booting after restoring an image of a dual boot system, refer to the section "Boot loaders: LILO and GRUB" for information specific to your boot loader.
--------------------------------------------------------------------------------

SuSE
SuSE is a popular version of Linux used in Europe. Ghost 7.0 and 7.5 have not been tested on SuSE, and we do not know at this time whether these Ghost versions are compatible with SuSE. Symantec Ghost 8.0 is compatible with SuSE.

Caldera Linux eDesktop 2.4
This Linux version includes a new boot loader called Grand Unified Boot Loader (GRUB), which is able to work with 8 GB and larger drives.

Norton Ghost 2003 and earlier do not support GRUB. Unofficial testing has shown that Ghost 7.5 and earlier can create and restore images of these drives, but that the restored system cannot boot up. To repair the restored system, boot the system with the disk you created during the Linux installation and follow the instructions for re-installing GRUB.

Boot loaders: LILO and GRUB
Each Ghost version that supports Linux supports the LILO boot loader.
To fix boot problems after cloning a system that uses the LILO boot loader
Boot the computer from the Linux rescue disk.
Log in as the root.
Run LILO.

Norton Ghost 2003 and earlier, and Symantec Ghost 7.5 and earlier do not support cloning Linux computers that use the Grand Unified Boot Loader (GRUB) because Ghost 7.5 and earlier cannot patch the GRUB. Restored systems using GRUB cannot start. To repair the restored computer, start the computer with the disk you created during the Linux installation and follow the instructions for re-installing GRUB. For related information, see the document Cannot start Linux with GRUB boot loader after restoring an image of a disk or partition.

Symantec Ghost 8.x does support GRUB.

Ghost does not support other Linux boot loaders.

Reiserfs
Reiserfs is a new type of Linux file system. Symantec Ghost versions 8.x and earlier do not support Reiserfs.

Symantec Ghost 7.0 and Norton Ghost 2002
Ghost 7.0 and 2002 include some fixes for Linux compatibility that were not included in previous Ghost versions. If you encounter problems cloning Linux disks or partitions with Ghost 6.5, upgrading to Ghost 7.0 might resolve the problem.

Ghost 7.0 and 2002 fixed the following problem in some instances:
Error: "Could not load NTSNX driver...The CMDS service is not started..." while starting the computer

Norton Ghost 2000, and Norton Ghost 5.1d and earlier
Versions of Ghost prior to 6.0 do not support Linux and will only allow a direct sector-by-sector clone of the entire drive.

Ghost 5.1d and earlier can correctly change partition sizes on FAT16, FAT32, and NTFS partitions only. When a drive is partitioned in a different format, Ghost can only perform a sector by sector copy. Sector by sector copies do not allow for there to be any changes in the geometry of the hard drive. Therefore, Ghost can be used to clone a drive to an identical drive for cloning or backup purposes. However, Ghost currently cannot be used to migrate a Linux partition.

References:
For more information regarding Symantec Ghost support for Linux, read Appendix E in the Symantec Ghost 7.5 Implementation Guide or Appendix F in the Symantec Ghost 8.0 Implementation Guide.

maspro
May 18th, 2005, 04:25 PM
Norton Ghost 2003 and earlier do not support GRUB. Unofficial testing has shown that Ghost 7.5 and earlier can create and restore images of these drives, but that the restored system cannot boot up. To repair the restored system, boot the system with the disk you created during the Linux installation and follow the instructions for re-installing GRUB.

That whole stuff about Grub not working and all is ********, I used Norton Ghost 2003 to back-up and restore Ubuntu with Grub and all works fine including the booting part. :smile:

Sam
May 18th, 2005, 04:33 PM
You just forget something:

Ghost:

http://img22.echo.cx/img22/8286/ghost3tp.png
Source (http://www.symantecstore.com/dr/sat1/ec_MAIN.Entry10?V1=646353&PN=1&SP=10023&xid=27674&CID=0&DSP=&CUR=840&PGRP=0&CACHE_ID=487820000157990)


Tar:

FREE !!!

Heliode
May 18th, 2005, 04:33 PM
That whole stuff about Grub not working and all is ********, I used Norton Ghost 2003 to back-up and restore Ubuntu with Grub and all works fine including the booting part. :smile:

Well, I guess you have to make a distinction here: There's two kinds of ghosts you can create; partition images and disk images. A partition image includes everything on a partition, and a disk image includes everything on a disk. Obviously, if you do a disk image, the bootloader (not just GRUB but also LiLO and whatever that thing Windows uses is called) is also included in the image. However, when you just do a partition image, that kind of stuff isn't included.

I find it strange how they list various operating systems that they support... why should ghost care about what kind of an operating system is on a disk/partition when it clones it? Isn't the filesystem its only concern? Or does this mean the actual program now runs on those Linux distributions?

But lets get things back on-topic! ;)

Anyone used this howto for backing stuff up already? Any related feedback?

maspro
May 18th, 2005, 04:47 PM
Well, I guess you have to make a distinction here: There's two kinds of ghosts you can create; partition images and disk images. A partition image includes everything on a partition, and a disk image includes everything on a disk. Obviously, if you do a disk image, the bootloader (not just GRUB but also LiLO and whatever that thing Windows uses is called) is also included in the image. However, when you just do a partition image, that kind of stuff isn't included.

I find it strange how they list various operating systems that they support... why should ghost care about what kind of an operating system is on a disk/partition when it clones it? Isn't the filesystem its only concern? Or does this mean the actual program now runs on those Linux distributions?

But lets get things back on-topic! ;)

Anyone used this howto for backing stuff up already? Any related feedback?
Well all that stuff about what OS is and isn't supported is kindoff strange indeed, you would say that EXT2/EXT3 is al the same in all Linux OS-ses. And indeed what you say about disk and partition images is true, I think it all depends where Grub is installed wether it will work or not.

But back on-topic indeed ;-) :
When I get around to it I will try your guide, because it can certainly come in handy, if I only knew of this guide sooner.... then I wouldn't have tried that whole Ghost stuff! :)

grakhul
May 18th, 2005, 04:52 PM
when I backuped in this method, my tar file was 948 MB so it could not fit on a cd-r. Also it wasn't a bootable image. Anyone have recommendations on how to create a bootable image that has been backup up?

Sam
May 18th, 2005, 04:55 PM
But lets get things back on-topic! ;)

Anyone used this howto for backing stuff up already? Any related feedback?
I just tryed to backup my system. It took 6 minutes (I've excluded the home which is TOO large). I didn't try the restore.

One thing, you chould change
tar xvpfz backup.tgzto
tar xvpfz backup.tgz -C /which extracts the archive to the root folder in the case you burned the archive to a CD or DVD.

ba5e
May 18th, 2005, 05:10 PM
I find it much easier and faster to buy a copy of Acronis True Image 8
http://www.acronis.com/homecomputing/products/trueimage/

this is super fast, and backs up by drive/partition, not file tree/strange method like above and supports even ReiserFS.

I wonder if someone will create an open source version someday?

Sam
May 18th, 2005, 05:15 PM
I find it much easier and faster to buy a copy of Acronis True Image 8
http://www.acronis.com/homecomputing/products/trueimage/

this is super fast, and backs up by drive/partition, not file tree/strange method like above and supports even ReiserFS.

I wonder if someone will create an open source vesion someday?
Yes, until then I won't pay $49.99....

Heliode
May 18th, 2005, 05:17 PM
I just tryed to backup my system. It took 6 minutes (I've excluded the home which is TOO large). I didn't try the restore.

One thing, you chould change
tar xvpfz backup.tgzto
tar xvpfz backup.tgz -C /which extracts the archive to the root folder in the case you burned the archive to a CD or DVD.

Thanks. I've updated the howto accordingly.


I find it much easier and faster to buy a copy of Acronis True Image 8
http://www.acronis.com/homecomputin...ucts/trueimage/

this is super fast, and backs up by drive/partition, not file tree/strange method like above and supports even ReiserFS.

I wonder if someone will create an open source vesion someday?


Same reason as for ghost: because it costs money. This method is free and can be done with tools that come with the system.

Just out of interest though, what about this do you find a 'strange method'? Is it so confusing to you that you are willing to spend $49 on a piece of software that probably does the same thing, but has pretty colors and things you can click on?

joekr
May 18th, 2005, 06:42 PM
Cheers, worked like a charm.

brickbat
May 18th, 2005, 07:04 PM
when I backuped in this method, my tar file was 948 MB so it could not fit on a cd-r. Also it wasn't a bootable image. Anyone have recommendations on how to create a bootable image that has been backup up?

Apparently you can use a (free) program called mondo rescue which backs up onto bootable media. I have installed it but haven't tested it yet.

ciao
bb

Sgood1971
May 18th, 2005, 07:47 PM
I've successfully used Ghost for Linux (https://sourceforge.net/projects/g4l) but you have to back up to FTP somewhere on your network or to the net. It works just like it says it does though. I really like the method here if I could find a way to break it into cd sized chunks.

remmelt
May 18th, 2005, 10:18 PM
nitpicking: the 'f' option in tar doesn't force anything, it tells tar to pack to a file instead of to stdout.

don't forget to umount any filesystems you may have, like samba's or home! (sure you still want to do it on a running server? :| )

for extreme packing, subsitute the 'z' for a 'j', so it will bzip2 the output. make sure you name the file .bz2 instead of .zip!

kingzasz
May 19th, 2005, 12:34 AM
I get his error when I try to run the command?

tar: Error exit delayed from previous errors

Any ideas?

jonrkc
May 19th, 2005, 03:09 AM
when I backuped in this method, my tar file was 948 MB so it could not fit on a cd-r. Also it wasn't a bootable image. Anyone have recommendations on how to create a bootable image that has been backup up?
You can use a utility called "split" (see man split) to break up a file or archive too large for one CD into CD-size segments, which you can then burn to as many CD's as it takes. You can specify the size of the segments, too.

I believe most CD-burning software has provision for making any CD you burn bootable if you wish (I know XCDRoast does), but it can be a bit tricky. Maybe somebody else will give clear instructions on that part.

Heliode
May 19th, 2005, 08:19 AM
I get his error when I try to run the command?

tar: Error exit delayed from previous errors

Any ideas?
That's the error I talked about that you might get. I Think its harmless. Your backup is probably alright.



nitpicking: the 'f' option in tar doesn't force anything, it tells tar to pack to a file instead of to stdout.
Whoops :roll:



don't forget to umount any filesystems you may have, like samba's or home! (sure you still want to do it on a running server? )

Well that's why I said to either unmount that stuff or exclude them. Excluding seems a fine thing to do on a running server to me ;)
Anything you don't want in your backup you can just exclude. The reason I advised people to unmount cd-roms and such is to keep complexity down. But of course, you can also just exclude them. Just make sure to re-create those directories after the restore.



for extreme packing, substitute the 'z' for a 'j', so it will bzip2 the output. make sure you name the file .bz2 instead of .zip!

Does .bz2 give you that much better compression? If so I'll have to change that. Thanks for the tip. By the way though; does it really matter what kind of extension you give the file? I thought that was a Windows CrazyThing too :P

jonrkc
May 19th, 2005, 09:10 AM
Does .bz2 give you that much better compression? If so I'll have to change that. Thanks for the tip. By the way though; does it really matter what kind of extension you give the file? I thought that was a Windows CrazyThing too :P
Bzip2 compresses quite a bit more than gzip or zip, but it's also quite a bit slower. The extension is handy to let users know how to expand the archive. For gzip'd files you use gunzip, but for bzip2'd files you have to use bunzip2. I guess if the archives were never going to be used by anybody else it wouldn't matter how you named them.

Heliode
May 19th, 2005, 09:28 AM
Bzip2 compresses quite a bit more than gzip or zip, but it's also quite a bit slower. The extension is handy to let users know how to expand the archive. For gzip'd files you use gunzip, but for bzip2'd files you have to use bunzip2. I guess if the archives were never going to be used by anybody else it wouldn't matter how you named them.

Ok, i'll add it to the howto as an alternative. I suppose you just substitude the z with a j in the extract command as well?

jeremy
May 19th, 2005, 10:55 AM
I do regular backups of my system using a knoppix cd and running partimage from that. In my experience partimage does the same as ghost or acronis true image, works just as well, and is FOSS! Partimage can be installed in ubuntu using apt-get.

Sam
May 19th, 2005, 11:33 AM
Ok, i'll add it to the howto as an alternative. I suppose you just substitude the z with a j in the extract command as well?
Of course...

Heliode
May 19th, 2005, 12:55 PM
A very good friend of mine warned me not to exclude /dev. He says the device nodes are not automatically regenerated. As i've personally never tried excluding /dev I don't think its save to include it in this guide, so I removed it again.

People who have already used this approach please take caution! To be sure you'll have to recreate your backup, this time including /dev !

Kyral
May 19th, 2005, 03:00 PM
Thanks for the Howto! Works great.

Just one question, how would I set this to run like every week?

Heliode
May 19th, 2005, 03:35 PM
Thanks for the Howto! Works great.

Just one question, how would I set this to run like every week?

Well, if you want to run this weekly, I suggest a somewhat different approach:
1: Create one backup of the whole system once, excluding the /home dir, and burn it to cd/store it on another PC

2: Create weekly backups of the /home dir only, which you overwrite every time.

That way, if your computer goes up in flames, you just restore the first backup followed by the second backup. If some program screwed something up, or you've been hacked, restore only the first one and have your system in the same state as when it was 'clean', but keep your home dir.
In another case; if something happens to your home dir (you accidently delete stuff, you lose a config file that is stored in your home dir, etc) you restore just the second kind of backup.

This has several advantages, some of which;
-when something goes wrong, you don't have to restore *everything*, and
-you don't have to wait for your whole system to be backed-up every week, only your home-dir.
-you have a way to restore your system to the state it was in when you first installed it, but keep your home directory.


You can create weekly backups by putting the backup command in 'cron.weekly', but I have no experience in manual cron configuration. Maybe someone else can help you with that.

Monkey_See
May 19th, 2005, 04:20 PM
Great HowTo, I like how you need absolutely no extra software to do it.


Apparently you can use a (free) program called mondo rescue which backs up onto bootable media. I have installed it but haven't tested it yet.

Yes, mondo is very good, it can create bootable CDs/DVDs of your system very easily. Mondo would be what I suggest for an initial backup of a clean system that is configured the way one wants it. That way if your system gets trashed, boot off the CD/DVD and restore, and you good to go again... but like ghost it will wipe all info. Also its in the repository.

jonrkc
May 19th, 2005, 04:54 PM
I do regular backups of my system using a knoppix cd and running partimage from that. In my experience partimage does the same as ghost or acronis true image, works just as well, and is FOSS! Partimage can be installed in ubuntu using apt-get.
I will have to give the partimage method a try. I obtained it via rpm package for Mandriva, before I switched a few days ago to Ubuntu, which I'm already liking a good deal better for several reasons. (I have nothing at all against Mandriva and am glad I was able to get started with Linux in Jan. 2003 using Mandrake.)

I have a live Ubuntu disc and if I ever succeed in understanding partimage well enough (it kind of intimidates me...) I'll at least give it a try.

Some very good suggestions in this thread for a task that should be among the most simple and basic, and yet can cause real frustration for Linux users: simply backing up a system.

jeremy
May 19th, 2005, 05:30 PM
Partimage is really quite easy to use, somewhat similar to ghost. As far as I know it isn't on the ubuntu live cd, which is why I use knoppix.
You should start partimage from a root console, and the partition that you are imaging should not be mounted. I make my images on a 2nd HD, then burn to dvd from ubuntu.

jonrkc
May 19th, 2005, 05:58 PM
Partimage is really quite easy to use, somewhat similar to ghost. As far as I know it isn't on the ubuntu live cd, which is why I use knoppix.
You should start partimage from a root console, and the partition that you are imaging should not be mounted. I make my images on a 2nd HD, then burn to dvd from ubuntu.
Partimage not on Ubuntu live: I should have thought of that! That's what comes of writing before my second cup of coffee (or third).

I'll download and burn a Knoppix Live CD and experiment, maybe this weekend. I have three hard drives so I ought to be able to do something safe as a learning experience...

jeremy
May 19th, 2005, 06:37 PM
Yes, play around with it, it's the best way to learn ;-)
When you've fired up knoppix, go to 'KNOPPIX' in the menu, then 'Root Shell', then type in 'partimage', it may say that it can't find something (can't remember what) and should it be created, say yes. -- I am telling you this because it took me a while to figure it out.

Good luck, and happy imaging!

tonybee
May 20th, 2005, 03:29 AM
MONDO is in synaptic!
home page is www.mondorescue.org

Rehevkor
May 23rd, 2005, 11:53 PM
I've managed to back up my Ubuntu install on my laptop to a windows network drive using this guide. Right now I'm backing up the stuff on the windows partition using Ghost.

When that's done, I'm going to format the drive clean and re-create my linux partitions, devoting the whole thing to Ubuntu :) Then I'm going to see if restoring from this tgz backup actually works :p

For those interested (and any who want to point out flaws) here is my restore plan:

1. Format the drive
2. Boot from my knoppix cd
3. Create a 1gb swap partition and an ext3 partition using the rest
4. Copy the tgz backup to the newly created root partition
5. Extract the backup as per the instructions in your guide
6. Reboot and hope for the best :)

jonrkc
May 24th, 2005, 12:04 AM
Using that method, will you have boot capability from the newly created Linux drive? That's the part that worries me about trying to transfer to another drive. I suppose if need be the boot record could be created later on, but it sounds to me like a golden opportunity to really mess things up. And I'm normally not afraid to experiment!

It's just that I lack practice and experience in transferring a whole system, and I don't want to have to spend days recreating all my stuff (even with backups of the home directory in a safe place, there's plenty more that's been customized and apps added, etc.)

Rehevkor
May 24th, 2005, 12:10 AM
GRUB should still work fine. I'm not actually going to format the entire drive, but rather delete the existing partitions, create new ones, and format them for linux. The MBR, where GRUB is installed, should be unchanged.

If all else fails, I could simply reinstall Ubuntu from the CD, then use it to copy the tgz backup into the root and extract it, overwriting the existing files. At least I *think* that would work...

jonrkc
May 24th, 2005, 12:55 AM
Good luck. Sounds like a workable plan to me... Be sure to report back with your results, OK?

lakcaj
May 24th, 2005, 02:14 AM
See my post later for an updated overview of the steps I took using the tar.gz method

Rehevkor
May 24th, 2005, 02:20 AM
In that case, I think I'll wait to attempt my re-partition and restore O_o

Thanks for the heads up.

jonrkc
May 24th, 2005, 03:51 AM
Lakcaj, I just want to say two things: (1) I admire anybody who can go through that experience and still both maintain a sense of humor AND write cogently; (2) I think I'll wait a while before attempting to transfer my Ubuntu to my big hard drive. :)

Rehevkor
May 25th, 2005, 12:32 AM
Isn't there some way to preserve the original file attributes and ownership when you extract them using tar? According the the man pages for tar the -p flag preserves permissions and --same-owner extracts files using the owner specified in the archive. Would that work?

lakcaj
May 25th, 2005, 01:17 AM
Rehevkor, what you said is true, but if knoppix does not have those users/groups in its system, it cannot create files that have those users/groups. Also, for root, the --same-owner is on by default, and you can see that we are using the -p option when we are using tar.

Now, I think I have things working correctly, so I will repost all the steps I took:
---------------------------------------------------------------------------------------------------------------------------

Backup your / partition, using tar, into 640 MB pieces. You will be prompted
each time to put in a new "tape". If backup.tgz is still in the same place
when you are prompted, tar will just start adding to it, so burn it
now and delete it. Don't forget to delete any iso's that where created
too. The following is one single command:

tar cpvM -L $((640*1024)) --exclude=/proc --exclude=/lost+found
--exclude=/backup.tgz --exclude=/sys --exclude=/tmp -f /backup.tgz /

Also, when you burn the tar ball, include a copy of the following, so that you can recreate the users and groups on the knoppix system:

/etc/group
/etc/passwd
/etc/gshadow
/etc/shadow
/etc/shadow.org


Boot into knoppix. To become root at any time, just type su in the terminal, there is no password.

Become root, and use cfdisk to partition your drive if necessary. You can then create the filesystems on the partitions. If you have changed the order of things, or are partitioning for the first time, reboot knoppix so it picks up the new partitions and adds them to its fstab and uses your swap partition.

Now, we get ready to start copying our files over to the new partition. We want to retain all the owner/group info of the original files, so we copy the 5 files we kept from our original system to /etc on the knoppix system. As root,

rm /etc/gshadow -f
cp /path/to/five/files/<filename x 5> /etc
chmod 766 /etc/group
chmod 766 /etc/gshadow

Now that you have done this, you may have trouble su'ing into root if you happen to log out. I found at this stage, the easiest thing to do is drop down into a tty, using ctrl-alt-f2. You will be root at this point. Just to make sure that we are sourcing the new passwd and group files, I "su -" again to root.

su -
cd

Mount the / partition, and copy the files back. You will be prompted for the
next CD. Make sure you aren't in the path of the CD, or you won't be
able to unmount the CD to put in the next one -- guess how I know this ;)

tar xvpfM /path/to/backup.tgz -C /path/to/mounted/root/partition

remake the /proc, /lost+found, /sys, and /tmp directories, and make sure that /tmp is writeable by all, and the sticky bit is set so that only the owner of a file in /tmp can alter it.

chmod 777 /path/to/tmp
chmod o+t /path/to/tmp

edit /boot/grub/menu.lst and /etc/fstab on the new partition if necessary

if you need to put grub on the MBR, do the following:

grub
root (hd0,#) where # is the / partition, numbering starting at 0
setup (hd0) this actually installs grub on the MBR
quit

notes - in the /dev/hda1 notation, the first partition starts with 1
- in the (hd0,0) notation, the first partition starts with 0
- so, (hd0,0) is the same as /dev/hda1

-----------------------------------------------------------------------------------------------------------------------

Well, that should be it. I just did a system restore using this method, and things appear to be just fine. It would be nice if some others could test it out so we can iron out the bugs before we commit to this being a reliable method of saving the state of a system.

Rehevkor
May 25th, 2005, 03:06 AM
I'm restoring from my backup right now. I followed your steps, although I wasn't able to eject the knoppix cd to extract the backup from my DVDRW. I had to put the backup.tgz in a shared folder on my windows desktop and do this:



mkdir /mnt/sharedfolder
smbmount //hostname/sharedfolder /mnt/sharedfolder
cd /mnt/sharedfolder
cp backup.tgz /mnt/hda2


/mnt/hda2 being my new root on the hard drive.

When it's finished restoring I'll update my GRUB config, remake the system folders, and see if it works. *crosses fingers*

Rehevkor
May 25th, 2005, 03:42 AM
Ok, I got it to boot... sort of. During the initial startup, everything looked ok except for these two lines:



WARNING: .udevdb already exists on the old /dev/!
...
/dev/hda2 has gone 49710 days without being checked, check forced


The login screen eventually appeared, but when I entered my username and password I got an error window:



Your session only lasted less than 10 seconds. If you
have not logged out yourself, this could mean that
there is some installation problem or that you may be
out of diskspace. Try logging in with one of the failsafe
sessions to see if you can fix this problem.

/etc/gdm/PreSession/Default: Registering your session with wtmp and utmp
/etc/gdm/PreSession/Default: running: /usr/bin/X11/sessreg -a -w /var/log/wtmp -u /var/run/utmp -x "/var/lib/gdm/:0.Xservers" -h "" -l ":0" "jcestep"
/etc/gdm/Xsession: Beginning session setup...
mkdtemp: private socket dir: Permission denied


Any idea what this is all about?

Edit: Forgot to mention, when I was copying the files necessary to re-create my user in knoppix, I discovered that I had no shadow.org file. All of the others were present, but not it. Could that have something to do with this?

Edit 2: Holy CRAP I fixed it O_o Apparently, /tmp must be world writeable, but re-creating it by hand gives it the wrong permissions. Thank you google :D

I booted to the login screen and hit ctrl-alt-f1 to drop to terminal, then did this:



sudo chmod 777 /tmp


I rebooted, and logged in without a problem. I wonder if this means I'm no longer a linux n00b :D

lakcaj
May 25th, 2005, 03:46 AM
Edit2 - make sure you set the sticky bit as well... see the text in my post above.

Edit - I was writing this post while you were writing yours, so I missed that you were initially having problems. Congradulations on getting it to work! I'll add your discovery about /tmp to my post above. I didn't get that error because I had included /tmp in my backup, and decided later that I didn't want it, so I included excluding it in the post which I'll use as a reference for myself in the future. Without other people trying it, I would have been in the same shoes as you not so far from now ;)



... although I wasn't able to eject the knoppix cd to extract the backup from my DVDRW.

That's correct, you can't remove knoppix while it is running. So, you need external access to the backup, either through your network, or another CD drive, etc. I have a usb DVD drive that I used. I tried and tried to find a way to make a bootable CD that would also have my backup, and basically, just type "restore" and have everything magically happen, but I couldn't find a reliable solution. The thing I like about this method so far is that, although it might be a little time consuming, I know _exactly_ what is happening at each stage, and can recover from errors easier. I also think this method is very versatile. I could boot from a linux distro on a usb thumb drive for example, and then use the CD drive go pull in my backup. Well, enough rambling, hopefully things go well for you.

Also, a BIG thanks to Heliode for his initial post. All I did was tie up some loose ends.

Rehevkor
May 25th, 2005, 05:36 AM
Thanks for that tip about the sticky bit.

Phew. Glad that actually worked :) Ubuntu is now the sole OS on my laptop. Excellent thread!

emendelson
June 4th, 2005, 05:16 PM
Heliode,

This method rescued my system from a total messup - many thanks. One question:

Although I *think* you concluded that it's unsafe to exclude /dev, it's still excluded in the initial howto (in the second code example, the bzip version) and the initial howto also says to mkdir /dev etc., even though I *think* it didn't get removed. Is this right, or am I muddying the waters here?

lakcaj
June 4th, 2005, 05:31 PM
I think the final decision was to include /dev in the tarball, and hence no need to remake the /dev directory after the restore.

I don't really have a reason one way or the other, but including /dev worked fine for me, so unless someone has an argument to the contrary, I will continue to backup my /dev directory.

Heliode
June 4th, 2005, 05:56 PM
Heliode,

This method rescued my system from a total messup - many thanks. One question:

Although I *think* you concluded that it's unsafe to exclude /dev, it's still excluded in the initial howto (in the second code example, the bzip version) and the initial howto also says to mkdir /dev etc., even though I *think* it didn't get removed. Is this right, or am I muddying the waters here?

Hey,

Thanks for pointing that out! Yes, I concluded it was unsafe to exclude /dev. I haven't actually tested this but a friend of mine (who generaly knows what he's talking about) warned me not to exclude /dev.

Original howto updated.

emendelson
June 4th, 2005, 06:24 PM
Thanks to you too! One more quick question: is there any reason NOT to exclude /var/log/* ???

nicholaspaul
June 5th, 2005, 07:07 AM
I have a question(S) - is there a way to do this over a network? What if I ssh to the machine to be backed up?

More questions: Does burning the resulting tar to a disc make it bootable?What I want is a custom made install disc of my own configuration.

Thanks :)

jonrkc
June 5th, 2005, 07:23 AM
Just burning a backup to a disc won't make it bootable, even if it seems to include all the directories. But all the front-ends for burning discs that I've used provide a way to make a disc bootable. They will pretty well guide you through the few steps needed. If you want the disc bootable, it's a good idea to burn it at a low speed to make sure you don't get any errors at all on it.

nicholaspaul
June 6th, 2005, 05:18 PM
Oh ok - thanks John. I have looked thru a few burning programs (Toast, K3b, GnomeBaker) and can't find a way to make a tar or the extracted version bootable. Am I really missing something here?

jonrkc
June 6th, 2005, 08:00 PM
Oh ok - thanks John. I have looked thru a few burning programs (Toast, K3b, GnomeBaker) and can't find a way to make a tar or the extracted version bootable. Am I really missing something here?
Well, sorry to say both k3b and xcdroast have decided either not to work at all (xcdroast) or to malfunction (k3b) on my system, so I'm unable fully to explore this.

In k3b, assuming you can get it to work, after you start a "new cd data project" and specify the .tar file you want to put on the CD, you then go to "project" on the top menu and choose "edit boot images" and go from there.

In xcdroast, under the "create cd > master tracks" menu there's a tab called "boot options." Clicking on that provides the way to instruct xcdroast to make the disc bootable. Normally you would want to choose the "El Torito" method.


I was actually going to create a bootable CD this way before replying here, but since neither of my CD-writing programs want to work just now, I'm unable to.

Can somebody else with more expertise and more COOPERATIVE software help out here, please?

Sorry to be so unhelpful; if I can get things working again I'll experiment and meanwhile I hope somebody else can help you.

nicholaspaul
June 6th, 2005, 11:51 PM
Actually you were very helpful ! Thanks!

While I have k3b working quite well (through no skill of my own, some things just happen... ) I did get an error while trying to make a bootable disc. I clicked on the file, selected Project> Edit Boot Image, clicked New and tried to burn. After adding the files, it anounced:

Size of boot image is 450228 sectors -> /usr/bin/mkisofs: Error - boot image '/tmp/kde-nicholas/k3bfs9D9a.tmp' has not an allowable size.
Fortunately it did this before making a coaster.
I get an error related to mkisofs when I try xcdroast too.. sounds like I should replace the user and try again.


If I had the files uncompressed on a CD , could I simply copy the files over in order to restore?

foxiness
June 7th, 2005, 05:03 AM
i'm plane to delete all partition on my harddisk than use the instrcation as on "Howto: Backup and restore your system!" what i need after i create partition for "xp" than the reset for ubuntu ,to restore the xp and ubuntu backup in removable-drive when i'm work on live cd ?

plane :
1-backup to /media/backup -removable harddisk - tar cvpfz backup-full-ubuntu-5.04-2005-06-06.tgz / --exclude=/proc --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/sys
2-delete allpartition
3-create part for xp vfat
4-create swap than the reset for /
5-restore xp to firest partion
6.1-restore ubuntu to 3rd one
6.2-mkdir proc , lost+found ,media ,mnt ,sys
7-restore grub
8-reboot

5 & 6 i think i need help here

#tar xvpfj backup.tar.bz2 -C /

i guess this will not work with me ?

foxiness
June 9th, 2005, 01:49 PM
i'm plane to delete all partition on my harddisk than use the instrcation as on "Howto: Backup and restore your system!" what i need after i create partition for "xp" than the reset for ubuntu ,to restore the xp and ubuntu backup in removable-drive when i'm work on live cd ?

plane :
1-backup to /media/backup -removable harddisk - tar cvpfz backup-full-ubuntu-5.04-2005-06-06.tgz / --exclude=/proc --exclude=/lost+found --exclude=/media --exclude=/mnt --exclude=/sys
2-delete allpartition
3-create part for xp vfat
4-create swap than the reset for /
5-restore xp to firest partion
6.1-restore ubuntu to 3rd one
6.2-mkdir proc , lost+found ,media ,mnt ,sys
7-restore grub
8-reboot

5 & 6 i think i need help here

#tar xvpfj backup.tar.bz2 -C /

i guess this will not work with me ?
k my note :

1- after i do all above but i forget to make dir sys mnt media proc lost+found

after the sys reboot its start fine and its create all dir exp mnt and media

and import to create media and /medai/cdrom0

than all thing right but

waring : udevdb alraedy exit on the old /dev/!

that is all thanks

szdavid
June 10th, 2005, 09:08 PM
Hello

i read all the seven pages ; a lot of discussions, really interesting but i am a real newbie so a few questions :
- does the howto on the first page work ? Is it the good one ?
- right now, i have two partitions : one for / and one for /home ;
how can i say during a restore "put /home in this partition and / to this one ?"

I think a good way in case of problem would be to install Ubuntu (like a new install) and after this, to restore my backup ; is it possible to restore / while i am using ubuntu or do I need to use a live cd ?

Thanks

Heliode
June 11th, 2005, 09:54 PM
Hello

i read all the seven pages ; a lot of discussions, really interesting but i am a real newbie so a few questions :
- does the howto on the first page work ? Is it the good one ?
- right now, i have two partitions : one for / and one for /home ;
how can i say during a restore "put /home in this partition and / to this one ?"

I think a good way in case of problem would be to install Ubuntu (like a new install) and after this, to restore my backup ; is it possible to restore / while i am using ubuntu or do I need to use a live cd ?

Thanks

Ok, there's a lot of questions in there, I'll try to answer them one by one.

1: The howto on the first page is what I use and what works for me. I've used it to backup several systems and it worked every time for me
2: If you want to have a backup of /home, just cd to / and run the correct command. In your case probably something like this:


# cd /
# sudo tar cvpfz homebak.tgz /home


If you want to backup /, just cd to /home and run the regular backup command, but this time exclude /home since it is on a seperate partition. This would make the commands look something like this:


# cd /home
# tar cvpfz backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/home


If you want to restore just the backup of the homedir, you would need something like this:


# cd /
# tar xvpfz backup.tgz -C /home


Be careful though: If you have a backup of / in your home-dir, it'll be overwritten when you restore your home-dir. (unless, of course, it is included in the archive but that wouldn't be very space-efficient ;))

The best would be to store the backup of /home on the / partition, and store the backup of the / partition on another machine or burn it to DVD or whatever.

As far as I know, it is possible to restore / on a running system. I've never tried it before but since it is also possible to erase everything in / on a running system, I figure why not! ;) I'm gonna need some confermation here though.
Of course you could always just use a live-cd. Usually when you have to restore /, you don't have an option anyway! ;)

Hope this helps!

szdavid
June 11th, 2005, 10:01 PM
Ok, there's a lot of questions in there, I'll try to answer them one by one.

1: The howto on the first page is what I use and what works for me. I've used it to backup several systems and it worked every time for me
2: If you want to have a backup of /home, just cd to / and run the correct command. In your case probably something like this:


# cd /
# sudo tar cvpfz homebak.tgz /home


If you want to backup /, just cd to /home and run the regular backup command, but this time exclude /home since it is on a seperate partition. This would make the commands look something like this:


# cd /home
# tar cvpfz backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/home


If you want to restore just the backup of the homedir, you would need something like this:


# cd /
# tar xvpfz backup.tgz -C /home


Be careful though: If you have a backup of / in your home-dir, it'll be overwritten when you restore your home-dir. (unless, of course, it is included in the archive but that wouldn't be very space-efficient ;))

The best would be to store the backup of /home on the / partition, and store the backup of the / partition on another machine or burn it to DVD or whatever.

As far as I know, it is possible to restore / on a running system. I've never tried it before but since it is also possible to erase everything in / on a running system, I figure why not! ;) I'm gonna need some confermation here though.
Of course you could always just use a live-cd. Usually when you have to restore /, you don't have an option anyway! ;)

Hope this helps!
Thanks a lot for these answers

jonrkc
June 11th, 2005, 10:03 PM
As far as I know, it is possible to restore / on a running system. I've never tried it before but since it is also possible to erase everything in / on a running system, I figure why not! ;) I'm gonna need some confermation here though.
Of course you could always just use a live-cd. Usually when you have to restore /, you don't have an option anyway! ;)

Hope this helps!
I don't believe it's safe to restore / on a running system--it may not even be possible. I tried it once and when it came to restoring libraries, the system crashed because the libraries needed for the restore process were of course temporarily put out of operation while being restored! So I would advise against trying.

I welcome correction by somebody that's expert, but that was my experience. I ended up having to rebuild my whole system from scratch.

Going from a live CD should be fine, though.

Lunde
June 17th, 2005, 08:10 AM
Nice howto!
But there are a coupple of issues.

1) Restoring the system did only overwrite without removing any files. There will be a lot of unneeded files on the harddrive.

2) I ignored the error you mentioned, removed all files from the disk and restored the backup but there are missing files like vmlinuz, initrd.img and maybe more.

3) this does not include empty directories. what if a program is dependent of writing and deleting from a directory which might be empty at the time you do the backup?

NOTE:

-l will stay in the same filesystem, no mounted drives or devices, may be better then the --exclude= option

--ignore-failed-read don’t exit with non-zero status on unreadable files. Will this remove the error during the backup?

cRoMo
June 21st, 2005, 03:55 PM
Why does excluding /mnt and the rest doesn't work here? I'm using breezy and backuping the way it is described in first post?

EDIT: There are few mistakens in the command line invoking tar to backup system, that are wrote in the first post. For some reason on certain versions of tar excluding of directories doesn't work. After my search on the google groups I found that these paths should look like that:

tar cvpfz backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

The only change is that the path that shows what should be backuped is at the end.

This change applies to bzip2 "version" respectively.

EDIT2: There's one more thing, this time about restoring the backup. Although there is an 'p' option given for preserving files modes, there is no option given to preserve same owner as of original files. Without it all of the files unpacked from the archive will become owned by the user who made unpacking. To prevent this we should add --same-owner option to the command line when unpacking. This, in most cases, will bring out some errors - that's when we are non-root user and want to set file owner to root. To prevent this, whe should run tar with sudo tool.

szdavid
June 24th, 2005, 07:56 PM
Hello,

I'd like to make an automatic script ; could you help me ?
I would like to say to start, for example, at 8:30pm
How to ?


And is it possible to say it "if the removable device where i ask you to backup is not mounted, do not do anything" ?

Thx

Muffe
July 3rd, 2005, 02:54 PM
The code you wrote in your first post:

tar cvpfz backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys

A quote from 'man tar':

-f, --file [HOSTNAME:]F
use archive file or device F (default "-", meaning stdin/stdout)

As far as I am able to understand, that means that the file in your example will be named z, and not backup.tgz. I have also tried exactly this command, with both gzip and bzip2 compression (z and j falgs), and the file names are z (for gzip) and j( for bzip2), not backup.tgz/backup.tar.bz2.

If i change the command to something like this:

tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
everything works fine. The error message that says 'tar: exit delayed from previous errors' also disapperars.

By the way: Check the comand for the bzip2 compression. It excludes backup.tgz, and not backup.tar.bz2 as it should do.

epb613
July 6th, 2005, 03:28 AM
The way I do it (so that you don't have to remake any directories):

Boot up off a live cd. Mount hda2 (my main partition).

type from anywhere: sudo tar cvzf /mnt/hda2/07052005.tgz /mnt/hda2/ --exclude=/mnt/hda2/07052005.tgz

Restore works basically the same way just now you don't have to remake the directories.

stefanoaguiar
July 6th, 2005, 08:13 PM
Hi there guys. Newba here.

I´m willing to move my current Ubuntu installation to another partition. Decided on it and need more drive space. To that, I´m repartitioning the whole thing, but I just don´t want to download all the updates again.

Based on this HOWTO I thought to do this:
1 - Backup up the system, as taught;
2 - Format and partition the drive accordingly;
3 - Install a brand new Ubuntu;
4 - Restore the backup of step 1;

Does that sound reasonable?

I thank you in advance for any help.
On time: been searching like a crazy on the forums, can´t find anything related that´s answered.

epb613
July 6th, 2005, 10:30 PM
Well if you format the entire drive you'll have to reinstall GRUB into the MBR, but this will happen anyway when you reinstall Ubuntu. After you resintall Ubuntu, if you then restore from your backup file, I think you should be fine. The only problem I could think of is if you change partitions (ie: you go from hda2 to hda3) then you may have a problem with GRUB not looking for your drive in the right place. I think this could be fixed easily though by editing your menu.lst file in /boot/grub and changing the location to hda3.

If it goes smooth, don't forget to write a howto when your done.

By the way, it could a better way to acomplish this is just to boot off a live cd and resize/move around your partitions with a partition editor. If you do this, still make sure to back up first.

ubuntufans
July 7th, 2005, 02:02 AM
this method doesnt work unless you run a livecd , i've tried moving from harddrive to another

mattheweast
July 17th, 2005, 11:56 PM
Awesome guide! I'm gonna port it to the wiki, hope that's ok? I'm just gonna take the first post, I guess that has all the updates discussed in the thread?

If you feel like it you can subscribe to the wiki page and maintain it as you have done with the forum post :)

The porting is part of an initiative we're doing to port some of the great material available on the forums to the Ubuntu wiki.

Thanks for your great work!

M

EDIT: Its here (https://wiki.ubuntu.com/BackupYourSystem?action=show) by the way ;)

scorpio2002
July 20th, 2005, 10:10 AM
Great guide! Just a question: will the backup work on a different hardware?

I mean, usually, when you change motherboard(and so the chipset) the operating system doesn't work anymore(for some reasons not well defined yet). This used to happen with windows, don't know if it happens also with linux.

My final question is: will my backup work if i buy a new moboard? :-P

frodon
July 28th, 2005, 01:00 PM
Yes, mondo is very good, it can create bootable CDs/DVDs of your system very easily. Mondo would be what I suggest for an initial backup of a clean system that is configured the way one wants it. That way if your system gets trashed, boot off the CD/DVD and restore, and you good to go again... but like ghost it will wipe all info. Also its in the repository.
Do you think you can restore with mondo a ghost image on a new drive (if you crash the old one) and have a full operational ubuntu partition ?

scorpio2002
July 30th, 2005, 02:08 PM
Do you think you can restore with mondo a ghost image on a new drive (if you crash the old one) and have a full operational ubuntu partition ?

Not sure, but I think so ^^

PokerFacePenguin
August 4th, 2005, 07:49 AM
Awesome thread. How about someone making it sticky?
Basic system administration with tools already possesed by the user.
Now just fire up your favorite shell and make it an executable script.
Maybe go the extra mile and put it in cron too!
\\:D/

matthew
August 23rd, 2005, 04:45 AM
I want to add a thank you to the OP for this howto...you just saved me a LOT of work. As outlined in this thread (http://ubuntuforums.org/showthread.php?p=314262#post314262) I had a hard drive failure today, but had done a backup using this method and all was restored perfectly.

You saved me a ton of time a work!! THANK YOU!!! Man, I love Ubuntu.

salle
August 24th, 2005, 12:39 PM
My final question is: will my backup work if i buy a new moboard? :-P

I have no experience above this, but I'd think so. At least if you're using stock Ubuntu kernel which has support compiled in it for most hardware (or you have included support to your own compiled kernel, for the new motherboard and made a backup afterwards) ? This same thing has crossed my mind, I'm going to try and move this Ubuntu installation to another hard drive in a completely different computer. Please, if you succeed in this, I'm interested to know!

chipmonk010
August 28th, 2005, 07:06 PM
First this howto/thread is great really helpful, but i have a couple questions that pertain to my perticular configuration.

i have two LVM xfs partitions /music and /videos they hold data only so i wouldnt want to back them up when making my tar. so if i exclude them in the backup, when i restore my system what will happen? will i get a / dir without these directories?

if i restore from my running system will it remove these folders from my / dir or will it just overwrite the other folders leaving these?

is there some other way i should do this?

thanks to all

mchatel
August 28th, 2005, 09:09 PM
Just a quick note...
I followed the instructions in this HOWTO, to backup my system.

I then deleted my Ubuntu partitions, and went through the full Ubuntu install again, because I wanted to make sure I could recover everything. Once the install was done, and I was logged into Ubuntu once again (but just the base install I had done), I then did the Restore command suggested in the HOWTO, and everything seems to have worked. Of course, the restore command was run as root.

The only thing I seemed to have trouble with, was once I rebooted, bring up Ubuntu with my "restored" system, my volume control was missing from the menu bar, and I couldn't run it. I kept getting an error about making sure to run "gst-register".

So I did. Once that was run, and I rebooted, everything was back to normal.

gst-register has a slightly different name in Ubuntu, but a search for the file should find it. I wasn't exactly sure what gst-register does. Can anyone comment on that. That is the only thing I found that I had to accomodate, outside of the HOWTO instructions.

FYI, I kept my same partitioning scheme I had used before. Not sure how much more work would be required, if someone wanted to separate out more partitions, or use LVM? I wouldn't mind trying LVM, but I have to do some more reading first.

chipmonk010
August 29th, 2005, 08:14 PM
well i think im gonna answer my own question here....

if i exclude my music and videos folders in the back up, reinstall ubuntu from scratch and keeping my partitioning scheme then run the restore it should be fine, it only overrites the folders in my / tree it does not overrite the / folder as a whole so i will still have my /music and video folders. so in theory it should work fine if restoreing without reinstalling ubuntu.

@mchatel
btw LVM is really a nice feature i highly recamend you give it a shot.

ssck
September 3rd, 2005, 03:12 AM
I have a noob question :-

If I wanted to restore my current system settings for the software that I have installed and the ubuntu desktop background, etc, after a fresh install of ubuntu, would backing up the home directory be sufficient ?

How do I back up the ~/. directories ?

Appreciate help.

Thanks.

wylie348
September 3rd, 2005, 04:58 PM
Nice thread - great points! I recently used mondo-rescue to backup my system after I did all the tweaking I wanted. I keep my data on a seperate partition and backed up my system to that partition and then backup my data to another place (off of my laptop). Works great. Did a restore for fun and no problems whatsoever with the system. I also think that mondo handles different HD geometries as well.
Ubuntu Rules!
:-P

vladuz976
September 12th, 2005, 11:23 AM
The way I do it (so that you don't have to remake any directories):

Boot up off a live cd. Mount hda2 (my main partition).

type from anywhere: sudo tar cvzf /mnt/hda2/07052005.tgz /mnt/hda2/ --exclude=/mnt/hda2/07052005.tgz

Restore works basically the same way just now you don't have to remake the directories.
is there a way i can have this run once a week automatically?

cutOff
September 12th, 2005, 01:35 PM
tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
Is there any way to know previously how much space will be used by the tar file?

Thanks

A-star
September 12th, 2005, 02:37 PM
Thanks for this guide,
I was looking for a long time now for a way to make a good backup.

cutOff
September 14th, 2005, 03:01 PM
tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
Is there any way to know previously how much space will be used by the tar file?

Thanks
Anyone? It would be very interesting to know it previously.

dudinatrix
September 14th, 2005, 03:13 PM
Is this HOWTO a good way to go about reformatting to install Breezy when it is officially released? I've been a Windows guy until the last few months (now 95% Linux!), so I've yet to have my first "format/reinstall" of Ubuntu (Kubuntu, specifically)... and I'm not quite sure the best way to go about it.

Is this the best way to do it? Obviously I wouldn't restore everything, but at least it should provide me with everything I'd need to get personal files and settings moved over right?

sal
September 17th, 2005, 09:34 PM
Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!

Most of you have probably used Windows before you started using Ubuntu. During that time you might have needed to backup and restore your system. For Windows you would need proprietary software for which you would have to reboot your machine and boot into a special environment in which you could perform the backing-up/restoring (programs like Norton Ghost).
During that time you might have wondered why it wasn't possible to just add the whole c:\ to a big zip-file. This is impossible because in Windows, there are lots of files you can't copy or overwrite while they are being used, and therefore you needed specialized software to handle this.

Well, I'm here to tell you that those things, just like rebooting (http://www.ubuntuforums.org/showthread.php?t=34629), are Windows CrazyThings (tm). There's no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter). In fact; using Ghost might be a very bad idea if you are using anything but ext2. Ext3, the default Ubuntu partition, is seen by Ghost as a damaged ext2 partition and does a very good job at screwing up your data.

1: Backing-up

"What should I use to backup my system then?" might you ask. Easy; the same thing you use to backup/compress everything else; TAR. Unlike Windows, Linux doesn't restrict root access to anything, so you can just throw every single file on a partition in a TAR file!

To do this, become root with


sudo su

and go to the root of your filesystem (we use this in our example, but you can go anywhere you want your backup to end up, including remote or removable drives.)


cd /


Now, below is the full command I would use to make a backup of my system:



tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys


Now, lets explain this a little bit.
The 'tar' part is, obviously, the program we're going to use.

'cvpfz' are the options we give to tar, like 'create archive' (obviously),
'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.

Next, the name the archive is going to get. backup.tgz in our example.

Next comes the root of the directory we want to backup. Since we want to backup everything; /

Now come the directories we want to exclude. We don't want to backup everything since some dirs aren't very useful to include. Also make sure you don't include the file itself, or else you'll get weird results.
You might also not want to include the /mnt folder if you have other partitions mounted there or you'll end up backing those up too. Also make sure you don't have anything mounted in /media (i.e. don't have any cd's or removable media mounted). Either that or exclude /media.

EDIT : kvidell suggests below we also exclude the /dev directory. I have other evidence that says it is very unwise to do so though.

Well, if the command agrees with you, hit enter (or return, whatever) and sit back&relax. This might take a while.

Afterwards you'll have a file called backup.tgz in the root of your filessytem, which is probably pretty large. Now you can burn it to DVD or move it to another machine, whatever you like!

EDIT2:
At the end of the process you might get a message along the lines of 'tar: Error exit delayed from previous errors' or something, but in most cases you can just ignore that.

Alternatively, you can use Bzip2 to compress your backup. This means higher compression but lower speed. If compression is important to you, just substitute
the 'z' in the command with 'j', and give the backup the right extension.
That would make the command look like this:



tar cvpjf backup.tar.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys


2: Restoring

Warning: Please, for goodness sake, be careful here. If you don't understand what you are doing here you might end up overwriting stuff that is important to you, so please take care!

Well, we'll just continue with our example from the previous chapter; the file backup.tgz in the root of the partition.

Once again, make sure you are root and that you and the backup file are in the root of the filesystem.

One of the beautiful things of Linux is that This'll work even on a running system; no need to screw around with boot-cd's or anything. Of course, if you've rendered your system unbootable you might have no choice but to use a live-cd, but the results are the same. You can even remove every single file of a Linux system while it is running with one command. I'm not giving you that command though! ;-)

Well, back on-topic.
This is the command that I would use:



tar xvpfz backup.tgz -C /


Or if you used bz2;



tar xvpfj backup.tar.bz2 -C /


WARNING: this will overwrite every single file on your partition with the one in the archive!

Just hit enter/return/your brother/whatever and watch the fireworks. Again, this might take a while. When it is done, you have a fully restored Ubuntu system! Just make sure that, before you do anything else, you re-create the directories you excluded:


mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
etc...


And when you reboot, everything should be the way it was when you made the backup!

2.1: GRUB restore
Now, if you want to move your system to a new harddisk or if you did something nasty to your GRUB (like, say, install Windows), You'll also need to reinstall GRUB.
There are several very good howto's on how to do that here on this forum, so i'm not going to reinvent the wheel. Instead, take a look here:

http://www.ubuntuforums.org/showthread.php?t=24113&highlight=grub+restore

There are a couple of methods proposed. I personally recommend the second one, posted by remmelt, since that has always worked for me.


Well that's it! I hope it was helpful!
As always, any feedback is appreciated!


how would one go about making this into a cron job to happen at certan times? could it be made into a script some how?
thanks.

Swoop
September 17th, 2005, 10:04 PM
Is this HOWTO a good way to go about reformatting to install Breezy when it is officially released? I've been a Windows guy until the last few months (now 95% Linux!), so I've yet to have my first "format/reinstall" of Ubuntu (Kubuntu, specifically)... and I'm not quite sure the best way to go about it.

Is this the best way to do it? Obviously I wouldn't restore everything, but at least it should provide me with everything I'd need to get personal files and settings moved over right?

Well i was wondering the same thing.
But without being the expert on this im guessing you need to exclude some more directories in order for this to work ?
Basiclly i would say the backup should take home directories, and perhaps a few other directories (i dont know really) .. i would certainly love to keep my scripts ect so i dont have to set everything up again.

Anyhow hopefully somebody will be doing a howto on this when breezy is released early october :D

Looking forward to it :D

NZ-Wanderer
September 20th, 2005, 12:53 AM
Hi all, well I tried it out last night, I copied and pasted from the first message (the second option cause I wanted more compression) into my terminal and away it went....

Not sure what happened, but I ended up with a 5 GB file, it didn't exclude anything (as I said above I copied and pasted from the first message)

Now when I go into "file browser" and try to delete the huge file the delete buttons are greyed out, so I can't even get rid of the file that was created..

Methinks I might just try copying my "home" folder to a fat32 partition and start all over again :) - might try Hoary instead of breezy this time..

(Yea, I new at this)

Regards - John...

mchatel
September 27th, 2005, 03:39 PM
Now when I go into "file browser" and try to delete the huge file the delete buttons are greyed out, so I can't even get rid of the file that was created..

Methinks I might just try copying my "home" folder to a fat32 partition and start all over again :) - might try Hoary instead of breezy this time..

(Yea, I new at this)

Regards - John...

Hi John.
You probably can't delete the file you created, because when you ran the "backup" tar command, you probably used SUDO, right? So, it was acting on root's behalf. You however are simply your own regular user, when using File Manager (File Browser? - sorry, can't remember the name offhand). So, you can either change the permissions/ownership of the backup file you created, or...

If you just want to delete it, you can use the following command from the terminal, using SUDO again.
sudo rm /backup.tgz
* this assumes backup file called backup.tgz was created in root filesystem
modify it to whatever name/location you used

NZ-Wanderer
September 27th, 2005, 08:08 PM
Thanks for that (takes notes for future reference)

I ended up reinstalling again as it was easier than mucking around.. :) - but I gradually getting the hang of this and am making fewer mistakes now.. - Have got my favourite windows file manager (total commander) working under wine now, so can use that to do any backups I want as it zips files on the fly..

fireboxtester
September 30th, 2005, 05:43 PM
Hey guys,
I just tried to use my backup file to restore my system and I get this error:
sys/module/rfcomm/sections/.strtab
tar: sys/module/rfcomm/sections/.strtab: Cannot open: File exists
tar: Error exit delayed from previous errors
Here are some details, let me know if you need to know anything else:
Running Breezy
Command to backup was
>sudo tar cvpjf backup.tgz.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz.bz2 --exclude=/mnt --exclude=/sys --excldue=/media
Command to restore was
> sudo tar xvpfj /backup.tgz.bz2 -C /
Let me know what you think. Any help would be greatly appriciated.
-Greg

sal
October 2nd, 2005, 11:31 PM
this method always worked for me in ubuntu 5.04 but yesterday i tryed
it in ubuntu 5.10 breezy and i noticed that although i used you exact command tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
it still tryed to back up /mnt so i had to cancel it because /mnt is where i have my second hard drive located with about 85gb of data.
could you tell me, is there something deferant i have to do in breezy?
thanks.

matthew
October 3rd, 2005, 12:12 AM
this method always worked for me in ubuntu 5.04 but yesterday i tryed
it in ubuntu 5.10 breezy and i noticed that although i used you exact command tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
it still tryed to back up /mnt so i had to cancel it because /mnt is where i have my second hard drive located with about 85gb of data.
could you tell me, is there something deferant i have to do in breezy?
thanks.
This didn't work for me in Breezy either. I posted a thread about it and the solution was to put the source directory at the end of the command. Using the command you have above, you would change it to read as follows:

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
Here's a link to my thread if you want more detail, but this change should take care of it. http://www.ubuntuforums.org/showthread.php?t=70566

sal
October 3rd, 2005, 12:17 AM
This didn't work for me in Breezy either. I posted a thread about it and the solution was to put the source directory at the end of the command. Using the command you have above, you would change it to read as follows:

Here's a link to my thread if you want more detail, but this change should take care of it. http://www.ubuntuforums.org/showthread.php?t=70566

thanks!! big time!!
i just installed breeezy the other day and now have it just the way i want. so i want to make the backup so in case anything gos wrong, i can recover very fast. ill look into your thread as well.
thanks again.

fireboxtester
October 3rd, 2005, 05:56 PM
This didn't work for me in Breezy either. I posted a thread about it and the solution was to put the source directory at the end of the command. Using the command you have above, you would change it to read as follows:
Quote:
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
Here's a link to my thread if you want more detail, but this change should take care of it. http://www.ubuntuforums.org/showthread.php?t=70566

Will this also fix my problem when I try to "unzip" it?
My Problem:

Hey guys,
I just tried to use my backup file to restore my system and I get this error:
sys/module/rfcomm/sections/.strtab
tar: sys/module/rfcomm/sections/.strtab: Cannot open: File exists
tar: Error exit delayed from previous errors
Here are some details, let me know if you need to know anything else:
Running Breezy
Command to backup was
>sudo tar cvpjf backup.tgz.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz.bz2 --exclude=/mnt --exclude=/sys --excldue=/media
Command to restore was
> sudo tar xvpfj /backup.tgz.bz2 -C /
Let me know what you think. Any help would be greatly appriciated.
-Greg
By the way, is there any way to test that my backup will in fact work without overwriting my whole filesystem?
-

matthew
October 3rd, 2005, 06:57 PM
Will this also fix my problem when I try to "unzip" it?
My Problem: I'm sorry, I have no idea. Your problem is unfamiliar to me, but hopefully someone else will chime in on it. I suppose if you want to live dangerously you could erase the whole hard drive/filesystem while Ubuntu is running and then restore the archive to that disk.

By the way, is there any way to test that my backup will in fact work without overwriting my whole filesystem? I don't think so. With a smaller archive you can just click on it in nautilus and see the contents. With something this big (my backup is 6Gb) it will either take a long time to open or just not work...it really is a huge file. You might be better off doing your backup in smaller bits if you have critical stuff that you need to be super safe and certain with, then you could test the backup archives easily.

blueshrike
October 4th, 2005, 05:47 AM
What is the best way to encrypt a backup before ftp-ing it offsite?

Thanks.

loksipan
October 4th, 2005, 11:04 AM
Could I install ubuntu on a spare HDD in an external USB enclosure, then copy everything under root from my main internal drive to the usb drive (with overwrite) to create an (almost) identical bootable copy?

Loksipan

linux_fish
October 10th, 2005, 02:41 AM
Using that method, will you have boot capability from the newly created Linux drive? That's the part that worries me about trying to transfer to another drive. I suppose if need be the boot record could be created later on, but it sounds to me like a golden opportunity to really mess things up. And I'm normally not afraid to experiment!

It's just that I lack practice and experience in transferring a whole system, and I don't want to have to spend days recreating all my stuff (even with backups of the home directory in a safe place, there's plenty more that's been customized and apps added, etc.)


will this back-up method preserve customizations to the system (thems, new apss etc.) ?

sal
October 10th, 2005, 12:04 PM
This didn't work for me in Breezy either. I posted a thread about it and the solution was to put the source directory at the end of the command. Using the command you have above, you would change it to read as follows:

Here's a link to my thread if you want more detail, but this change should take care of it. http://www.ubuntuforums.org/showthread.php?t=70566

worked like a charm!
thanks.

matthew
October 10th, 2005, 07:26 PM
worked like a charm!
thanks.
You're welcome.

ephman
October 24th, 2005, 05:47 AM
hi,

is there anything to worry about my archive? this is the first time i've ever done this.

tar: /backup.tar.bz2: file changed as we read it
tar: --exclude=/proc: Cannot stat: No such file or directory
tar: --exclude=/lost+found: Cannot stat: No such file or directory
tar: --exclude=/backup.tar.bz2: Cannot stat: No such file or directory
tar: --exclude=/mnt: Cannot stat: No such file or directory
tar: --exclude=/sys: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors

thanks,
ephman

tonderai
October 24th, 2005, 07:04 PM
Excellent guide :)

I'd like to try this, but I have very limited space on this hard drive (laptop) and I'm pretty certain I don't have room to generate the backup here. Is there a way to redirect the resulting backup.tgz to shared folder on my windows network instead of a local partition? Perhaps by using smbmount to mount the share, then create the backup.tgz from that location?

I was rather puzzled by the seemingly excellent compression of my >15GB system down to 2GB over Samba to a network drive, and even more so when a backup of only my /home produced exactly the same result. I found I had run into the Samba 2GB file size limit (see this thread (http://www.ubuntuforums.org/showthread.php?t=68261)) - which could be really dangerous if you didn't realise your backup had been cut short.

To solve this, you need to use the lfs option when mounting your network drive i.e.


sudo mount -t smbfs -o lfs,username=,password= //network_computer/network_drive /mnt/share/

nicholaspaul
November 16th, 2005, 07:13 PM
I'm having a bit of trouble with excluding my other hard drive. Its mounted as /media/rothko but
--exclude=/mnt or --exclude=/media/rothko don't exclude it. Is there a way to exclude /media/rothko and all the subdirectories?

nicholaspaul
November 22nd, 2005, 08:46 PM
This didn't work for me in Breezy either. I posted a thread about it and the solution was to put the source directory at the end of the command. Using the command you have above, you would change it to read as follows:

Here's a link to my thread if you want more detail, but this change should take care of it. http://www.ubuntuforums.org/showthread.php?t=70566

This worked for me too. I guess the moral is 'read the whole post ' :-\

Thanks matthew!

Eversmann
December 2nd, 2005, 12:41 AM
Once thing guys, i've read the whole thread (AWESOME, big thanks), and my question is: What do i have to do to backup the system and restore in a new brand one?

I'm changimg my computer to a new one, totally different one. So, what do i have to do?
Backup everything (excluding /dev i suppose, the drives and devices are different), then install ubuntu from CD and then restore everything? Will I keep everything like i have actually (desktop configuration...)

Thanks for your advices guys, i keep learning more and more because of you ;-)

nicholaspaul
December 2nd, 2005, 12:50 AM
Once thing guys, i've read the whole thread (AWESOME, big thanks), and my question is: What do i have to do to backup the system and restore in a new brand one?

I'm changimg my computer to a new one, totally different one. So, what do i have to do?
Backup everything (excluding /dev i suppose, the drives and devices are different), then install ubuntu from CD and then restore everything? Will I keep everything like i have actually (desktop configuration...)

Thanks for your advices guys, i keep learning more and more because of you ;-)

If you want to keep your configuration (desktop set up), passwords, bookmarks, emails etc, I would just backup you Home directory (inc all the hidden files). Correct me if I'm wrong, but that should be all you need. Then do a fresh install. If you're doing a backup to make your life easier (!) then doing a fresh install would do that - it would recognise your drives and devices.

TrumpetMan258
December 3rd, 2005, 05:51 PM
I backed up my home directory, but when I try to open the archive, I get this error message:

An error occurred while loading the archive.
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now


I know that I typed the backup command into ternimal correctly. How come I can't open the archive?

kellyhardinguk
December 15th, 2005, 06:53 AM
this method doesnt work unless you run a livecd , i've tried moving from harddrive to another

The method listed in this HOW-TO works very well for backups, it is one I use regularly on my network at home :)

You need to do things slightly differently if you want to migrate to a new hard drive or move a partition to a new drive or similar.

I'll give a quick example.

You have two hard drives /dev/hda and /dev/hdb. /de/hda is your curren system/old drive, /dev/hdb being your new drive you want to move to.

First install the new hard drive in your machine and mount it somewhere.

For instance /mnt/newhdd perhaps.

Then use the following command:

(cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xvfp - )

Substitute /source/directory for the directory you want to transfer over (ie /home. Substitute /dest/directory for the directory where the new drive is (ie /mnt/newhdd/home).

For example, say you wanted to copy over your /etc dir to your new drive (remember to create the dir on the new drive first):

(cd /etc && tar cf - . ) | (cd /mnt/newhdd/etc && tar xvfp - )

That should copy the contents of /etc to /mnt/newhdd without any problems.

You can repeat this for each dir on the system you want to transfer.

This method works very well I've found if you've run out of space on a hard drive and want to move just part of the filesystem to another drive (ie your home dir perhaps).

I've used it to migrate my Debian servers to new/bigger hard drives before now, and it should work on any Debian based distro (Knoppix/Ubuntu, et al) without too many problems.

Theres more info on the Debian reference guide about various methods of doing this here (http://www.debian.org/doc/manuals/reference/ch-tips.en.html#s-archiving)

Hope this proves helpful.


Kelly Harding
--
Ubuntu Breezy - Compaq Presario 1200, Ubuntu Breezy/XP Pro - Athlon 64 3000+, Debian 'unstable' - dual P/II-350, OpenZaurus/Opie - Sharp Zaurus SL-5500, Mac OS X 10.2 - Apple PowerMac G3

kellyhardinguk
December 15th, 2005, 06:57 AM
I backed up my home directory, but when I try to open the archive, I get this error message:


I know that I typed the backup command into ternimal correctly. How come I can't open the archive?

Something went wrong with the creation or copying of the backup somewhere/how.

It is telling you it cannot read the file because it is shorter than it should be.

Did you get any errors whilst making the backup?

Is the file over 2Gb? if so what filesystem was it put on/copied to? IIRC FAT32 has a filesize limit of 2Gb/file.

Kelly

xtacocorex
December 19th, 2005, 05:37 PM
I have this method set up in a shell script to back up my / and /home separately, but the exclude doesn't work anymore (it did with Hoary).

I tried changing the order in the tar command, but that still doesn't work.

I'm including the code for / (/home is pretty much identical, with the exception of different excludes)



#!/bin/sh

# This is a shell script to back up the root directory of my
# computer and move it to an externally mounted harddisk for
# storage
#
# To restore root system backup, use resbkrt

# Get current directory
mycurrdir=`pwd`

# Change to /media/hd?
cd /media/usbdisk/backups

# Clean out /var/cache/apt/archives
echo "Cleaning apt-get cache"
sudo apt-get clean

# Exclude variables
ex1="--exclude=/home --exclude=/proc --exclude=/lost+found"
ex2="--exclude=/mnt --exclude=/sys"
ex3="--exclude=/tmp --exclude=/media"
#ex4="--exclude=/var/cache/apt/archives"

# Create .tgz backup file as superuser
# Don't need to include /home -> to be done in a different script
echo "Creating backup archive"
sudo tar cvpzf rootbackup-`date +%F`.tgz $ex1 $ex2 $ex3 /

# Go back to original directory
cd $mycurrdir

xtacocorex
December 20th, 2005, 04:26 AM
This is definately odd as my script now works with the excludes.

PokerFacePenguin
December 20th, 2005, 06:04 AM
EDIT: There are few mistakens in the command line invoking tar to backup system, that are wrote in the first post. For some reason on certain versions of tar excluding of directories doesn't work. After my search on the google groups I found that these paths should look like that:

tar cvpfz backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

The only change is that the path that shows what should be backuped is at the end.

This change applies to bzip2 "version" respectively.

EDIT2: There's one more thing, this time about restoring the backup. Although there is an 'p' option given for preserving files modes, there is no option given to preserve same owner as of original files. Without it all of the files unpacked from the archive will become owned by the user who made unpacking. To prevent this we should add --same-owner option to the command line when unpacking. This, in most cases, will bring out some errors - that's when we are non-root user and want to set file owner to root. To prevent this, whe should run tar with sudo tool.

I believe this should be included as a footnote in the original post. The --exclude stumped me for a bit. Nice HOWTO.

tsugaguy
January 8th, 2006, 06:57 PM
i'm a complete linux idiot but i hate windows enough to keep trying this. could somebody give us a revised version of the 2 commands from the first post above so that they exclude whatever dev folders there are that waste space or cause problems? it would be a great help! t:smile: hanks!!!!!!!!!!

daller
January 9th, 2006, 01:20 AM
I have installed mondo from the repos!

How do I run it?

nicholaspaul
January 9th, 2006, 05:09 AM
I have installed mondo from the repos!

How do I run it?

Personally, I would "do a search and check out the guides" .
I Googled "mondo linux" and found http://www.mondorescue.org

galgoz
January 13th, 2006, 11:03 AM
Ok, I had a system that was Dual Boot WinXP and Ubuntu. I made my backup of Ubuntu following these directions and burned it to DVD. I then did the following:

1. Deleted all partitions
2. Reinstalled Ubuntu 5.10
3. Copied tar image to /
4. Restored the image using the command in the first post
5. Rebooted

Or I should say I tried. It just sat at >Grub

I had no idea what to do. So I deleted the partitions and reinstalled Ubuntu 5.10 again.

That is where I am now? Should I try the restore again? I didn't recreate the directores that were excluded but I don't think I needed to as they should have been created by the fresh installation right?

shane2peru
January 18th, 2006, 03:02 AM
Ok, first thanks for the HOWTO it was a great and very extremely helpful guide! I had to completely re-install Ubuntu. I then restored by backup that was over 3GB! It worked like a charm twice. (The first time I forgot to use sudo :oops: ) so it took about an hour to restore my home partition, and then got to the root, and well, didn't have write permissions. The second time worked like a charm.
Now, my only problem is that my little sound icon by the clock has an ugly x over it. I do have sound, but it gives me this error when I click on it,
The volume control did not find any elements and/or devices to control. This means either that you don't have the right GStreamer plugins installed, or that you don't have a sound card configured.

You can remove the volume control from the panel by right-clicking the speaker icon on the panel and selecting "Remove From Panel" from the menu.

If I right click on it and select open I get this error,

Registry is not present or it is corrupted, please update it by running gst-register

When I attempt to run gst-register it in the terminal I get this
bash: gst-register: command not found
Any ideas? Oh, also I didn't have this problem before my backup. Thanks!

Shane

pauljwells
January 18th, 2006, 01:34 PM
I had the same problem, gst-register worked though and solved it. gst-register is part of libgstreamer0.8-0 Just run synaptic and install it and you should be sorted.

shane2peru
January 18th, 2006, 05:02 PM
It claims that that is installed? All I need to type in the command line is
gst-register I tried that and sudo before it. Nothing. Maybe I need to un-install and re-install these programs to get them to work right? I don't know, any other ideas? Thanks.

Shane

henshu70
January 29th, 2006, 03:58 PM
Hi there,

Great guide! I am completely new to Ubuntu and Linux so I really appreciate there is a very simple way to backup your installation. That way I do not have to reinstall again and again. The whole backup went fine, however, when I tried to restore the system, I ran into serious problems. Again, everything went well until:


sys/module/rfcomm/sections/.strtab

tar: sys/module/rfcomm/sections/.strtab: Cannot open: File exists

tar: Error exit delayed from previous errors

And the whole process is finished automatically. This happens whether I run it from booted system or 'failsafe Terminal'. Does anybody know how to overcome this problem? Can also somebody give an instruction how to restore from Live CD (absolute beginners please)?

Thanks

Renko
January 29th, 2006, 11:00 PM
I did use this backup method this weekend on Suse with TAR (GNU) 1.15.1. The documentation how it is in the topicstart is broken for 1.15.1, it will create a corrupt unusable backup.

See this:
http://www.cygwin.com/ml/cygwin/2005-10/msg00956.html

This is a right command to backup:

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

instead of

tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys

With the wrong command, TAR1.15.1 ignores the 'exclude' options so it will stop in the sys dir (then your backup is incomplete). In case it doesn't stop it will continue, on the end you get the following error:

tar: --exclude=test1: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors

I'm useing the commands 'time' and 'nice' too now. 'time' tells how long it did take to create the backup, 'nice' sets the CPU proriority on low, so the backup process does not interupt other applications.

time nice -n +15 tar cvpzf /backup/290106.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup --exclude=/mnt --exclude=/sys --exclude=/media --exclude=/windows /

Perhaps does Ubuntu use another version of TAR where the 'wrong' command will be accepted. Anyway, I think it's wise to warn you to prevent huge troubles.

slim_chiply
February 3rd, 2006, 05:45 PM
Renko appears to be correct with this. I found the same problem with Breezy. I was backing up my home directory and did an --exclude=.Trash. I happened to notice .Trash in the output while it was doing the tar. I followed Renko's suggestion and it no longer ignored the --exclude.

jerome bettis
February 4th, 2006, 04:45 AM
i've been developing 2 python scripts for awhile now to legimately backup and restore. it's a pretty nice system but i haven't used it with ubuntu yet. it's a pain to type all of those commands and usually nothing goes right. this is supposed to solve that problem ..

i'm going to retool them a bit and when they're ready i'll post them. basically the idea is you boot into knoppix, mount some other drive to store the tarballs on and type one command. it tarballs all your partitions individually, copies the MBR, partition table, fstab and whatever else. then the restore script asks you what to restore.

it worked in gentoo but ubuntu is a little different. and it's not interactive yet, once i get that going i'll post them, probably in a few days or so.

]Nbx*cmD[
February 5th, 2006, 02:20 PM
Hmm i find there's something missing in this HowTo, once we have the backup file we would want to have it saved out the computer, so i suggest using multicd (apt-get install multicd) which is a ~20kb utility which works awesome.

zasf
February 6th, 2006, 10:24 AM
Excellent guide, I love the idea that you can save your system and restore it later without the hassle to go trought an installation process and all the consequent customization.

I followed this howto on my system, here is a brief resume: zipping 2gb of fresh dapper flight3 install took 30 min on my 2GHz centrino and resulted in a 500mb bz2 file. Unzipping took 15 min.

There are some corrections wich I would make on the first post:

the tar command should be corrected, if don't put '/' at the end of the command, '--exclude' doesn't work, this determinated a big loss of time for me. The tar command seems to be different, according to ubuntu version, thus a distinguish should be made.
including /dev doesn't result in doubling the zipped file as posted by kvidell, that message scared me a little, it could be nice to ask who posted it to delete it as it's very early in the thread and imho a lot of people read it.
it is wise to check the size of /tmp, purge it if necessary and then include it, otherwise you incour in the '10 sec section' error as poste by Rehevkor and you have to do other manual activities. On my system /tmp is cleaned at every boot, so it could be a nice idea to perform the zip command right after boot.


Thanks!

porcho
February 23rd, 2006, 12:40 AM
Hey, I've repartitioned my HDD, and backing up/restoring my system as explained surely saved me a lot of time. Excellent guide!!!
Here's a brief resume of what I did:

a) Backed up my system as explained (I'm using Breezy), placing the source directory at the end of the tar command so that the exclude options would work (as explained in this thread (http://www.ubuntuforums.org/showthread.php?t=70566));
b)Installed Windows XP;
c) Repartitioned my HDD using Breezy Install CD partitioner;
d) Restored the backup, using the --same-owner option in tar as advised by some users in this thread. I've created the same users after installing, so that wasn't a problem for me when restoring;
e) Commited some mistakes that made me spent some time figuring out what happened! :)

I'm a real newbie. I'll report the errors so that others may avoid them in the future:

i) Overwrite the /etc/fstab file with the one from the previous installation: that's not a problem as long as you don't change your partition table after backing up. Well, I did! I had to fix it by hand afterwards, following this guide (http://www.psychocats.net/linux/mountwindows.php) and this one (http://www.tuxfiles.org/linuxhelp/fstab.html).

So, when restoring after repartitioning, be sure not to overwrite the /etc/fstab file!

ii)Overwrite the /boot/grub/menu.lst file (GRUB menu entries) with the one from the previous installation: as with the fstab file, you're most likely to get a correctly configured GRUB after Ubuntu installation. Overwriting GRUB menu entries file with the previous one may prevent your system from booting in an OS; because the partition numbers might not match with the current ones.

So, when restoring after repartitioning, be sure not to overwrite the /boot/grub/menu.lst file!

Well, that's it. Thank you all!

entryname
March 26th, 2006, 09:22 PM
Hello.

What I'd ideally like to do is not put a large backup file on the hard disk, which has some value due to the "whoops I didn't meant to do that" scenario, but to back up the whole lot to a set of CDs the first one of which is bootable, so that you only have to boot from the first disk and then keep feeding it till it runs out of disks. In short, the same as "Image for Windows" does.

I'm not clear from your how to on how I get this large file onto a set of CDs.

I did try Mondo which looked like it did what I wanted, but it appeared to complain about a syntax error in Mindi. I then tried downloading and compiling the current version but that wouldn't compile, apparently having problems with compilers (I tried two or three). I then tried BackupPC but that refused to configure and I can't in any case find either the file or a menu entry to run it with, so I guess I'll have to give up on that as well and take if off again. I had a look at ghost for linux (G4L) which appears to be a 28MB download with an ISO option. I did baulk at this, especially as the CD drive making the backups would be a USB external.

Can the how to be amended to either include or point at some means of making disk images of linux systems, or at least a statement that this isn't possible and the nearest to it that can be done i.e. backup onto a set of CDs/DVDs?

Out of interest, suppose I were to copy files directly onto CDs by dragging and dropping using Graveman, and then after the disaster boot from a live CD and then copy the files from the CDs back onto a blank hard disk. Would this work, or would system files not have copied due to being in use etc?

Out of further interest, is Graveman equivalent to K3B, and would K3B run under gnome? (sorry for all the questions)

Copter
March 31st, 2006, 06:14 PM
This didn't work for me in Breezy either. I posted a thread about it and the solution was to put the source directory at the end of the command. Using the command you have above, you would change it to read as follows:

Here's a link to my thread if you want more detail, but this change should take care of it. http://www.ubuntuforums.org/showthread.php?t=70566
thnx! i was wondering whats going wrong here ;-)

copter :]

McLogic
April 11th, 2006, 10:19 PM
Just make sure that, before you do anything else, you re-create the directories you excluded:


mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
etc...


And when you reboot, everything should be the way it was when you made the backup!


People will need to add mount points for cdrom and other partitions. My cdrom didn't work until I made the mount point.



mkdir /media/cdrom0
mkdir /media/usbdisk
mkdir /dos


anyone have a list of things that need to be done after restore?

tsharpe62
April 12th, 2006, 11:51 PM
How can I delete the backup.gtz file out of my root?

sal
April 14th, 2006, 12:44 PM
How can I delete the backup.gtz file out of my root?

one all done you just do an sudo rm /backup.tgz

daller
April 14th, 2006, 07:18 PM
Use PartImage!?

http://www.partimage.org/Main_Page

...Seems like a nice backup/restore tool!

likeatim
May 6th, 2006, 09:22 PM
Another suggestion: DAR

sudo apt-get install dar
then

sudo kate dar_backup.sh

something like this

#!/bin/sh

DIR=/backups
FILE=${DIR}/`/bin/date -I`_data
# Commands
dar -m 256 -y -D -R / -c `date -I`_data -Z "*.avi" -Z "*.dar" -P media -P tmp -P mnt -P lost+found -P sys
dar -t $FILE > /dev/null

likeatim
May 7th, 2006, 04:57 PM
Another suggestion: DAR
or even better: kdar
very convenient, does all of the above even easier....

ztirffritz
May 7th, 2006, 07:55 PM
Has anyone done this using RSYNC? I'd really like to know how to do this with RSYNC because it seems more useful to me. I'm a Mac guy and I'm trying to find something the recreates Carbon Copy Cloner. Haven't found anything yet. I tried to install Mondo, but it seems to have disappeared. I'm not sure where it went.

superuser
May 14th, 2006, 06:28 PM
Hello!

Based on the suggestions in this thread, I've created a backup suite that needs as less knowledge and input from the user as you could imagine: you only have to call it, the rest will be automatically done for you by the software suite.

This is the systembackup suite, version systembackup-suite-0.1 by
Moritz Beller

Usage: ./backup.sh

In order to run the script, you need the following programs installed:
bash, tar (gzip)

To perform a backup, run ./backup.sh. This will generate a TAR file
which includes everything you need to restore the saved system state
from a Linux live or rescue system. What you do to go backup to the
system state that was saved within the TAR file is to tar -cf FILENAME
the generated file on the Linux rescue system. This will create a
directory called FILENAME (without the extension). You only have to cd
to it and call the ./restore.sh script. It is important that you know
where you mounted your former / partition as the script will
interactivley ask you where to put the backuped system.

systembackup-suite-0.1 is Free Software and you may exert it under the
terms of the GPL as distributed with your systembackup suite copy.

Here is the link: Go, try and test it! (http://www.4momo.de/artikel__show_db__other__130.htm) I am open to further improvements and suggestions.

superuser

tagra123
May 22nd, 2006, 04:08 AM
Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!

Most of you have probably used Windows before you started using Ubuntu. During that time you might have needed to backup and restore your system. For Windows you would need proprietary software for which you would have to reboot your machine and boot into a special environment in which you could perform the backing-up/restoring (programs like Norton Ghost).
During that time you might have wondered why it wasn't possible to just add the whole c:\ to a big zip-file. This is impossible because in Windows, there are lots of files you can't copy or overwrite while they are being used, and therefore you needed specialized software to handle this.

Well, I'm here to tell you that those things, just like rebooting (http://www.ubuntuforums.org/showthread.php?t=34629), are Windows CrazyThings (tm). There's no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter). In fact; using Ghost might be a very bad idea if you are using anything but ext2. Ext3, the default Ubuntu partition, is seen by Ghost as a damaged ext2 partition and does a very good job at screwing up your data.

1: Backing-up

"What should I use to backup my system then?" might you ask. Easy; the same thing you use to backup/compress everything else; TAR. Unlike Windows, Linux doesn't restrict root access to anything, so you can just throw every single file on a partition in a TAR file!

To do this, become root with


sudo su

and go to the root of your filesystem (we use this in our example, but you can go anywhere you want your backup to end up, including remote or removable drives.)


cd /


Now, below is the full command I would use to make a backup of my system:



tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys


Now, lets explain this a little bit.
The 'tar' part is, obviously, the program we're going to use.

'cvpfz' are the options we give to tar, like 'create archive' (obviously),
'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.

Next, the name the archive is going to get. backup.tgz in our example.

Next comes the root of the directory we want to backup. Since we want to backup everything; /

Now come the directories we want to exclude. We don't want to backup everything since some dirs aren't very useful to include. Also make sure you don't include the file itself, or else you'll get weird results.
You might also not want to include the /mnt folder if you have other partitions mounted there or you'll end up backing those up too. Also make sure you don't have anything mounted in /media (i.e. don't have any cd's or removable media mounted). Either that or exclude /media.

EDIT : kvidell suggests below we also exclude the /dev directory. I have other evidence that says it is very unwise to do so though.

Well, if the command agrees with you, hit enter (or return, whatever) and sit back&relax. This might take a while.

Afterwards you'll have a file called backup.tgz in the root of your filessytem, which is probably pretty large. Now you can burn it to DVD or move it to another machine, whatever you like!

EDIT2:
At the end of the process you might get a message along the lines of 'tar: Error exit delayed from previous errors' or something, but in most cases you can just ignore that.

Alternatively, you can use Bzip2 to compress your backup. This means higher compression but lower speed. If compression is important to you, just substitute
the 'z' in the command with 'j', and give the backup the right extension.
That would make the command look like this:



tar cvpjf backup.tar.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys


2: Restoring

Warning: Please, for goodness sake, be careful here. If you don't understand what you are doing here you might end up overwriting stuff that is important to you, so please take care!

Well, we'll just continue with our example from the previous chapter; the file backup.tgz in the root of the partition.

Once again, make sure you are root and that you and the backup file are in the root of the filesystem.

One of the beautiful things of Linux is that This'll work even on a running system; no need to screw around with boot-cd's or anything. Of course, if you've rendered your system unbootable you might have no choice but to use a live-cd, but the results are the same. You can even remove every single file of a Linux system while it is running with one command. I'm not giving you that command though! ;-)

Well, back on-topic.
This is the command that I would use:



tar xvpfz backup.tgz -C /


Or if you used bz2;



tar xvpfj backup.tar.bz2 -C /


WARNING: this will overwrite every single file on your partition with the one in the archive!

Just hit enter/return/your brother/whatever and watch the fireworks. Again, this might take a while. When it is done, you have a fully restored Ubuntu system! Just make sure that, before you do anything else, you re-create the directories you excluded:


mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
etc...


And when you reboot, everything should be the way it was when you made the backup!

2.1: GRUB restore
Now, if you want to move your system to a new harddisk or if you did something nasty to your GRUB (like, say, install Windows), You'll also need to reinstall GRUB.
There are several very good howto's on how to do that here on this forum, so i'm not going to reinvent the wheel. Instead, take a look here:

http://www.ubuntuforums.org/showthread.php?t=24113&highlight=grub+restore

There are a couple of methods proposed. I personally recommend the second one, posted by remmelt, since that has always worked for me.


Well that's it! I hope it was helpful!
As always, any feedback is appreciated!


TAR VERSION: tar (GNU tar) 1.15.1

In this version the exclude arguments need to come before anything else.

To backup:

As listed (will not exclude the directories and files)


tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys



Should be (this will exclude the directories and files):


tar --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys -cvpzf backup.tgz /

See this link for more: http://www.ubuntuforums.org/showthread.php?t=147501

jonrkc
May 24th, 2006, 09:49 AM
It might be worthwhile--and save some grief later--to make a "test" directory with several subdirectories, and put any old files in those directories (and in the "test" directory itself) and experiment with using tar archiving and restoring on this material that has no value.

As pointed out in several posts, there are different versions of tar in existence, and they do have quirky variations that can lead to bad archives or none at all, though I doubt that under any conceivable normal scenario the use of tar to CREATE an archive could hurt anything apart from using up lots of disc space unnecessarily.

On the other hand, if a mistake is made in RESTORING from a tar archive--one of the most common and easiest errors is to be in the wrong directory when you give the command, or otherwise to fail to state exactly where to put the restored directories and/or files--then there is a possibility of serious trouble. At the least, you might end up with an enormous cleanup task. (As another poster put it, "Guess how I know this.")

So I'd suggest experimenting with harmless material first--if possible, on a hard disk separate from the one you'll eventually be doing your "serious" work with. That way you can play around all you want, and become familiar with some of the literally hundreds of variations available with the enormously powerful and useful, but potentially dangerous, tar command. (Like learning to drive in a parking lot.)

You can download the big tar manual in easy-to-read PDF form from the GNU/tar homepage. I doubt that anybody except maybe some tar developers know everything that is in it.

Sbarton
May 26th, 2006, 07:51 PM
Tonight I was going to post about how to clone my (linux) setup and after doing a search came to this post. As a windows user of many years I have used third party software to 'clone' my drives for quite some time, and on a regular basis. My experience has been 3 clicks (maybe4) of the mouse and it's done! Simple, easy! A great end user experience! After reading this post,PHEW!!!
I am going to continue to search!
Regards

jonrkc
May 26th, 2006, 08:11 PM
After reading this post,PHEW!!!
I am going to continue to search!
Regards
Me, too... This how-to is admirable and I hope it helps a lot of people backup their systems, but I just don't want such complexity.

The best thing I've found so far is a script called rdiff (a Google search should turn it up easily), which is extraordinarily powerful and, once you set your parameters for it, it can operate automatically via cron, or be started with a keystroke or mouse click if you wish. It will not "ghost" or clone a drive, but it will save every last thing on the drive if you want it to. That way you can completely reinstall everything as of the last backup with rdiff, as soon as your system is up and running again following whatever catastrophe has taken place.

It is also very useful for simply restoring files that you wish you hadn't deleted. You can go back as far as the archives go, that you've kept.

It does operate command-line only, but it can be a lifesaver.

I'm going to investigate kdar, but after trying to use dar itself once or twice, I have no high hopes.

I'm just not willing to devote a large chunk of whatever years I have left to learning to implement and use something extremely complex. When I was younger, maybe that would have been fun, but now in late middle age it most assuredly is not.

Sbarton
May 26th, 2006, 08:25 PM
jonrkc, Guess you agree then! No matter how powerful a process is it needs to be user friendly and EASY!
Regards

jonrkc
May 26th, 2006, 08:46 PM
jonrkc, Guess you agree then! No matter how powerful a process is it needs to be user friendly and EASY!
RegardsThat's why Gnome desktop environment, KDE, and other GUI-based working (and playing) environments came to be: There's a heavy demand for user-friendliness.

I have utmost respect for geekiness and highly technically minded users. They're the ones that made Linux a living reality for all of us. But there are many different kinds of users with valid reasons for using Linux.

So when I come across something heavily technical I feel grateful that there are users that are pursuing that and making further basic development--as well as frills-- possible. I just don't fall into that camp. I well could have, at one time. Now I'm glad to have Xfce and IceWM and other GUI tools to make my use of Linux easier. It was very hard for me to get where I am now, three years after swearing off that big money-making OS 95% of people use, and turning solely to Linux. I just don't crave any more technical struggles!

Sgood1971
May 30th, 2006, 06:51 PM
If you are looking for a way to quickly image your system, Acronis True Image works great for Linux. Just create and boot from a rescue CD into a full GUI acronis from which you can image away, it recognizes USB disks, Zip Drives, Network Shares, just about anything you want to put your image on. It's how I back up all of my Linux and Windows Installs. Of course it is a non-free alternative.

philetus
May 31st, 2006, 05:45 AM
Just make sure that, before you do anything else, you re-create the directories you excluded:
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys etc...

Empty directories?

shahramsfamily
June 8th, 2006, 09:47 AM
thank you for your tutorial:
but the" --exclude=/media" command does not work so far as excluding the folder /media in draper which i added to the list of excludes.
it just start backing up all my hard drives, unless I don't use the root directory as the path.

xfile087
June 12th, 2006, 12:45 AM
Hey guys,
I just tried to use my backup file to restore my system and I get this error:
sys/module/rfcomm/sections/.strtab
tar: sys/module/rfcomm/sections/.strtab: Cannot open: File exists
tar: Error exit delayed from previous errors
Here are some details, let me know if you need to know anything else:
Running Breezy
Command to backup was
>sudo tar cvpjf backup.tgz.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz.bz2 --exclude=/mnt --exclude=/sys --excldue=/media
Command to restore was
> sudo tar xvpfj /backup.tgz.bz2 -C /
Let me know what you think. Any help would be greatly appriciated.
-Greg

Did you ever get it fixed? I have the same problem

CameronCalver
June 24th, 2006, 12:56 AM
i get this error at the end

/opt/linuxdcpp/build/gui/wulfor.o
/opt/linuxdcpp/build/gui/mainwindow.o
/opt/linuxdcpp/build/gui/bookentry.o
/opt/linuxdcpp/build/gui/wulformanager.o
/opt/linuxdcpp/build/gui/selecter.o
/opt/linuxdcpp/.sconsign
/opt/linuxdcpp/dcpp
/opt/linuxdcpp/config.log
/opt/linuxdcpp/SConstruct
/opt/linuxdcpp/Readme.txt
/opt/linuxdcpp/License.txt
/opt/linuxdcpp/Credits.txt
/opt/linuxdcpp/Changelog.txt
/initrd/
/vmlinuz
/debootstrap/
/debootstrap/debootstrap.log
/usplash_fifo
/initrd.img.old
/vmlinuz.old
tar: --exclude=/proc: Cannot stat: No such file or directory
tar: --exclude=/lost+found: Cannot stat: No such file or directory
tar: --exclude=/backup.tgz: Cannot stat: No such file or directory
tar: --exclude=/mnt: Cannot stat: No such file or directory
tar: --exclude=/sys: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
root@ubuntu:/#

brownrl
June 28th, 2006, 01:05 AM
Norton Ghost seems the best from what I read here for going from one HD to the another HD. A simple tar file won't do GRUB and will require directory excluding and directory making later on. Could some one put either a proper howTo for transferring a complete system to another hard drive or say once and for all ghost is the tool to use?

As for the people who complain about having to pay for it: Here's a hint... The P-Bay has incredible deals on commercial software.


Grtz
R

warchild77
July 7th, 2006, 05:33 AM
I'm using Dapper and there seems to be a new command format for tar. Now the --exclude statements need to go before the source directory....

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

Even easier...you can create a file with the words you want to exclude and use the --exclude-from=FILE. See my example below but don't copy/paste it unless you created a file called 'excludes'.


tar cvpzf backup.tgz --exclude_from=excludes /

Hope that helps.

beebelo
July 7th, 2006, 04:04 PM
After reading and investigating this issue I settled on System Rescue CD (http://www.sysresccd.org/Main_Page). There are many excellent tools on this bootable cd. The backup utility is partimage. It backs up by partition into a tar gz, from which individual files are still accessible. Check it out!

CGW
July 7th, 2006, 09:32 PM
Is it me or (possibly just Dapper?) do you have to enter the restore code like this:


tar -c xvpfz backup.tgz /

instead of this?:


tar xvpfz backup.tgz -C /


I couldn't get the restore to work until I made these changes.

CGW
July 8th, 2006, 02:41 AM
*

jonrkc
July 8th, 2006, 03:34 AM
If I'm not mistaken, the "f" has to be the last thing before the file name you're expanding. The "v" ought to show you (in detail!) what's going on; if you see nothing happening it's because...nothing's happening. I've noticed that tar sometimes doesn't give any error message when it's simply not doing anything.

I just tested with some files, and with the "z" last nothing happened (except I did get an error message), and with the "f" last, I got the archive expanded normally.

I'm pretty shaky with tar, but I believe this may be what's wrong.

CGW
July 8th, 2006, 04:55 AM
Actually I just rebooted and copied the same line of code into the terminal and it worked fine. I copied it both times instead of typing it--so I'm not sure what happened. It just finished 'restoring' and everything seems fine. I'm not sure what went wrong.

tonderai
July 9th, 2006, 01:10 PM
I'm using Dapper and there seems to be a new command format for tar. Now the --exclude statements need to go before the source directory....

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

Even easier...you can create a file with the words you want to exclude and use the --exclude-from=FILE. See my example below but don't copy/paste it unless you created a file called 'excludes'.


tar cvpzf backup.tgz --exclude_from=excludes /

Hope that helps.

I was wondering why none of the excludes worked now - thanks, you saved me a lot of time! Can we get the original post updated?

What is the format for the 'excludes' file? Is it just a list of directories on separate lines?

Thanks, David.

cyran0
July 14th, 2006, 12:38 PM
I didn't notice this mentioned before, but I may have missed it.

The above problems with excluded files not being excluded are in all likelihood the sources of the erros that produce

tar: Error exit delayed from previous errors

You *should not* get this error message at the end of your output, and if you do get it, you should investigate!

It would be great to have the original post updated.

punkybouy
July 16th, 2006, 09:42 PM
Is the command ever supposed to exit out? Mine ran for quite awhile and left me with just a blinking cursor for about 15 minutes. I had to do a ctrl C to get back to a prompt. It did create the file which is about 2 GB. How do I know it finisihed?

CGW
July 16th, 2006, 09:44 PM
Providing your code was right you should see the files being 'backed-up' as they scroll up the terminal screen.

A 2GB backup will take a few minutes--15 minutes is probably a tad long. I'd do it again to make sure.

fer5437
July 24th, 2006, 09:20 AM
I will try this out but dont know success or not

tukster
July 24th, 2006, 07:58 PM
5+ for this guide.
it was a life saver :p

shoki
July 31st, 2006, 12:56 AM
Hello,

I included --exclude=/media to the back up command but the back up still seemed to back up the thumb drive... I can just unpulg the thing but what am I doing wrong?



tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/media

...

/media/
/media/cdrom
/media/cdrom0/
/media/SWIJUMP/
/media/SWIJUMP/-1_PodCasts/
/media/SWIJUMP/-1_PodCasts/this WEEK in TECH - MP3 Edition/
...



Thank you,
--Shoki

adamkane
July 31st, 2006, 02:21 AM
Use sbackup. It's just a shell for tar, but it is so much easier to use.

supersrbin2000
August 2nd, 2006, 04:11 AM
this whole thing sounds really great, but i have very annoying problem with 'tar' command: it won't exclude anything! No matter what i did, it just kept ignoring --exclude=/dir statements ](*,) ...could anyone, please, give me the solution, cause i have to backup my system as soon as possible. thanx.

jonrkc
August 2nd, 2006, 04:47 AM
this whole thing sounds really great, but i have very annoying problem with 'tar' command: it won't exclude anything! No matter what i did, it just kept ignoring --exclude=/dir statements ](*,) ...could anyone, please, give me the solution, cause i have to backup my system as soon as possible. thanx.
I believe it's easiest to use the -X option in tar (long form is --exclude-from). Just make a text file called, say, exclusions, with the name of one file or directory you don't want backed up on each line of the file. Then put in your tar command -X exclusions (or --exclude-from exclusions) and tar will exclude the files it finds recorded in the file you wrote. When you want to change exclusions it's easy, because you just have to modify that simple text file instead of maybe making a mistake in some long tar command line.

I hope this helps.

supersrbin2000
August 2nd, 2006, 03:08 PM
well, what i did was:
1. i gedited file 'exclusions' in my home dir:
"/media
/... " (so, i put each dir in a separate line)
2. i went to /media/hdb5 (which is the partition i want to put backup.tgz on) and typed:
$ tar cvpzf backup.tgz / --exclude-from=/home/myUsername/exclusions
i also tried -X, and nothing happened: tar kept ignoring exclusion statement. i am a newbie, as you can see, but this IS the right syntax for tar, is it not? :) i'm affraid that i'll have to ask for a complete 'idiot friendly' instructions :confused:

supersrbin2000
August 2nd, 2006, 04:36 PM
well, what i did was:
$ tar cvpzf backup.tgz / --exclude-from=/home/myUsername/exclusions
i also tried -X, and nothing happened: tar kept ignoring exclusion statement. i am a newbie, as you can see, but this IS the right syntax for tar, is it not? :)

it seems it's not :), when i entered:
$ tar --exclude-from=/<path-to-file> -cvpzf backup.tgz /
tar finnaly excluded those files. Jonrkc, thank you very much for helping me. I really think this is more elegant solution.
I just wanted to ask few more things: even though it seems from the console output that it packed every single file on partition (except excluded, ofcourse), i can't find some of those files in backup.tgz (/vmlinuz...), so i would like to know if they are present or not? Secondly, could anyone tell which system files & directories are irrelevant for backup, so i could, even without them, restore my system in previous state? I hope I'm not asking too much ;)

jonrkc
August 2nd, 2006, 05:22 PM
it seems it's not :), when i entered:
$ tar --exclude-from=/<path-to-file> -cvpzf backup.tgz /
tar finnaly excluded those files. Jonrkc, thank you very much for helping me. I really think this is more elegant solution.
I just wanted to ask few more things: even though it seems from the console output that it packed every single file on partition (except excluded, ofcourse), i can't find some of those files in backup.tgz (/vmlinuz...), so i would like to know if they are present or not? Secondly, could anyone tell which system files & directories are irrelevant for backup, so i could, even without them, restore my system in previous state? I hope I'm not asking too much ;)
I'm very glad it worked--at least the exclusion part. I was just about to post about the order of the options, when I saw your post quoted above where you'd got it right.

As for asking too much, I don't think a user can ever ask too much. A system should do what the user wants. I know this is heresy to some "gurus," but for us more down-to-earth users, I think it's perfectly reasonable to want computers to do things for us, and not vice-versa.

Anyway.

As far as I can see, your /vmlinuz should be there. It's not a special file that tar doesn't know how to handle... That puzzles me. I'll do a little experimenting and see what I can find out.

What directories/files might as well be excluded is a subject of debate. Most seem to feel the /var and /tmp directories should always be excluded, as well as /proc. There is a lot of debate (to judge from what I've seen) over /sys. My own feeling is--if you have lots of disk space or media space to use, why not just back everything up anyway? You don't have to restore it all.

A utility such as partimage which creates a supposedly (!) faithful copy of a partition, will back up every last thing there, and partimage is used for restoration by a lot of people, including myself at least once. I feel uneasy using partimage, though; it's poorly presented to the user and that makes me have doubts, even though many, many swear by it.

I'd say leave out /proc, /var, and /tmp and keep everything else. Or leave them in.

seelk
August 2nd, 2006, 06:31 PM
Is it possible to use the backup file over and over and only it backs up files that are new or different? (I apologize if this was covered in the thread. I'm at work and didn't get a chance to read the whole thread.)

supersrbin2000
August 3rd, 2006, 10:57 AM
I'm very glad it worked--at least the exclusion part. I was just about to post about the order of the options, when I saw your post quoted above where you'd got it right.
Thanx again for help. I'm trying to learn this basic stuff as soon as possible, so i did a bit of investigating, instead of just sitting and waiting for someone to do all the work. Hope that soon I'll be able to help someone too ;)


As far as I can see, your /vmlinuz should be there. It's not a special file that tar doesn't know how to handle... That puzzles me. I'll do a little experimenting and see what I can find out.
Yeah, I don't see the reason why it shouldn't be there, there was nothing in console output that stated different. I'm very interested in the results of your experimenting, so, if you have the time, please post it.


A utility such as partimage which creates a supposedly (!) faithful copy of a partition, will back up every last thing there, and partimage is used for restoration by a lot of people, including myself at least once. I feel uneasy using partimage, though; it's poorly presented to the user and that makes me have doubts, even though many, many swear by it.
Yes, i've tried PartImage, but didn't got how to unmount / partition...anyway, this approach sounds easier for me. I'll get back to testing PartImage as soon as i learn more about Linux and Ubuntu.


I'd say leave out /proc, /var, and /tmp and keep everything else. Or leave them in.
Roger that ;)

gapplewagen
August 3rd, 2006, 06:17 PM
How about this one...

I originally installed Ubuntu 6.06 LTS on a standard IDE drive because I wasn't sure if I was going to completely dump Win XP. I have no decided that I am going to completely kill XP in favor of Ubuntu. I have everything configured exactly how I want it on the IDE drive.

What I'd like to do is backup/restore the data from the IDE drive (ubuntu) onto the drive that my XP installation was on. Here's the catch... the XP drive is an SATA drive. I'm assuming that a backup/restore to the SATA drive would not work because of fstab and Grub.

I'm going to attempt this tonight and was just wondering if anyone had any pointers or if anyone had tried it before. I'm going to follow this guide for backing up the old IDE drive to an external USB. Then I plan on beginning a default Ubuntu installation using the CD. I will partition the drive, let grub do it's thing, and then try to restore. I'm wondering if I should edit fstab before I do the restore though to set the correct / disk and whatnot. Are there any other files I would have to edit?

supersrbin2000
August 4th, 2006, 07:47 PM
One important thing is missing in this great howto, so i feel responsibility to share my recent experience with other newbies, who could get counfused if they get stuck in trying to do what i did just now :)
My idea was to backup the whole sys, change the partition table, and then reinstall and revitalise Ubuntu as it was. I did that because i had insufficient space, resulting from giving too little space to Ubuntu, as many newbies do. This is the situation in which this howto should (and must)not be implemented without modifications:
1. exclude /etc/fstab and /etc/mtab
this is because new system will have its own mounting patterns, and it will redirect all extracting files in the appropriate locations.

2. install Ubuntu and edit the partition table

3. copy backup archive in / and extract the files

4. now you have to do something to make your sys boot properly - gedit the /boot/grub/menu.lst and enter right informations about your root whereabouts.

5. reboot

This will, hopefully, restore your system in a previous state. It worked for me, though.

P.S. Personally, I think that this is an excellent proof of Linux's flexibility. I'm definitely starting to like Linux more each day :)

zasdarq
August 5th, 2006, 12:35 PM
I have backed up everything as the instructions said and am now trying to recover using my backup. It goes through it for a couple minutes, then gives this error and hangs up 'till giving up:

sys/module/michale_mic/
tar: sys/module/michael_mic: cannot mkdir: Operation not permitted

Which, I guess clearly means that my exclude didn't work, since sys shouldn't have been backed up. I noticed now at the end of the thread that someone else found that that command didn't exclude for them either, I didn't think to check. Is it possible to still recover from this backup?

Thanks!
Matthew

gapplewagen
August 5th, 2006, 04:29 PM
I have backed up everything as the instructions said and am now trying to recover using my backup. It goes through it for a couple minutes, then gives this error and hangs up 'till giving up:

sys/module/michale_mic/
tar: sys/module/michael_mic: cannot mkdir: Operation not permitted

Which, I guess clearly means that my exclude didn't work, since sys shouldn't have been backed up. I noticed now at the end of the thread that someone else found that that command didn't exclude for them either, I didn't think to check. Is it possible to still recover from this backup?

Thanks!
Matthew
If you have the enough space I'd imagine that you could extract the backup file somewhere else (like /tmp/workingbackup or an external HD) and then delete the files/dirs that you intended to be exluded. Then tar the workingbackup directory and restore it to /.

Flavian
August 7th, 2006, 12:30 PM
Exactly! ;) Just make sure you exclude the mounted folder or you'll end up backupping your Windows drive as well! ;)

Can you maybe explain that to me step by step, as you did it in your how-to
Since I am a newbie in that area, I don't quiet get it and I don't want to do things the wrong way :/

Also there seems to be an error, if I put


tar cvpjf backup.tar.bz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys --exclude=/etc/fstab --exclude=/etc/mtab --exclude=/media

in the terminal it makes a backup of the data from the other hard drives mounted anyways :(
Any solution, did I do something wrong?

Thanks in advance
Flo

Flavian
August 7th, 2006, 05:12 PM
I fixed the problem with the hard drives, by unmounting them totally.
But it seems as if it ignores the excludes commands totally.

Rightnow it is trying to pack itself, as posted in the howto it should not be!
What did I do wrong?

OmahaVike
August 8th, 2006, 02:31 AM
Would anyone with some directory structure knowledge be so kind as to confirm the following exclude syntax?

I'm using 6.06, so the source directory reportedly has to be declared at the end of the statement.


tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/etc --exclude=/boot --exclude=/dev /

Here's what i'm trying to do. TestMachine has Ubuntu installed the way I want it (preferences), with the appropriate applications installed.

I want to move my installed proggies and settings over to a whole new machine (intel vs. amd, different IDE structure, etc.) I'm planning on a fresh install of 6.06 on the NewMachine, and then untar the file made by the statement above.

I have tried to identify those directories which would change given a different CPU, memory, storage and Mobo architecture. While I have trust in the underlying HAL of Ubuntu, I'm not 100% sold on a pure drag-n-drop migration.

Any and all help is greatly appreciated.

htmlguy716
August 9th, 2006, 03:52 PM
I am running Dapper 6.06 LTS and I want to make a complete backup of my system (without backing up any user folders), so I tried the following command as root:

tar cvpzf "/home/danielcox/Backups/Ubuntu System 2006-8-9.tgz" / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/home
Oddly enough, tar started running through my home folder partway through the backup, which I specifically told it to exclude. Any ideas?

Thank you,
Daniel

Flavian
August 9th, 2006, 04:38 PM
Oddly enough, tar started running through my home folder partway through the backup, which I specifically told it to exclude. Any ideas?


Same thing here! I don't know why...
And no one seems to answer here either :(

OmahaVike
August 9th, 2006, 05:16 PM
I am running Dapper 6.06 LTS and I want to make a complete backup of my system (without backing up any user folders), so I tried the following command as root:

tar cvpzf "/home/danielcox/Backups/Ubuntu System 2006-8-9.tgz" / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/home
Oddly enough, tar started running through my home folder partway through the backup, which I specifically told it to exclude. Any ideas?

Thank you,
Daniel

i thought i read in this particular thread that ubuntu requires the path to be at the end of the statement. try this, and let us know if it worked:


tar cvpzf "/home/danielcox/Backups/Ubuntu System 2006-8-9.tgz" --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/home /

htmlguy716
August 11th, 2006, 05:25 AM
OmahaVike,
Thank you very much for the help. The new command worked like a cup of fresh-brewed Ubuntu. I can now make regular backups of my system, while keeping my data separate.
-Daniel Cox

waldschm
August 11th, 2006, 04:19 PM
I ran into a problem while using this method to backup to an external USB hard drive. The external hard drive is 120GB single partition formatted as vfat for use with Windows and Linux and my internal has 9 partitions either ntfs or ext3 totalling about 40GB. When I tried to backup I ran into a size limitation I believe originating from the vfat format of the external. Maybe somebody with more experience in this area could address how to use split and cat to create pieces and then reassemble them? I nearly nuked everything had I not noticed the archive size was suspiciously small. A warning or modification in the howto might be useful as well.

namityadav
August 18th, 2006, 12:34 AM
Why isn't 'rsync' considered in the last 20 pages of this backup guide? Rsync is used as a backup tool at a lot of places and it has a very obvious benefit of updating through diffs.

Moreover, you can use rsync through ssh to backup your data to a remote machine (For example, I backup my laptop's data to the desktop at work).

# rsync -a --delete -e "ssh -c blowfish -ax " $source/ $userid@$backuphost:$backupdir/$source/

wimvanherp
August 22nd, 2006, 07:38 PM
I think there is an error in your commandline for tar : the last item should be the directories that will be tarred, if you don't do it the excludes wont be taken in account . So to my opinion this is a correct syntax :
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

regards

Ozz
August 22nd, 2006, 09:54 PM
If I create a cron job to do this, how could I get the backup.tgz moved over to my file server (Windows Server 2003)?
smbmount maybe? What's the best option there?
Thanks,

Ozz.

p.i.m.p
August 27th, 2006, 11:11 AM
I think there is an error in your commandline for tar : the last item should be the directories that will be tarred, if you don't do it the excludes wont be taken in account . So to my opinion this is a correct syntax :
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

regards

hey thanks.. it works for me now :)

airjrdn
September 4th, 2006, 05:12 AM
I got everything working the way I wanted it, did the backup, then moved that to my fileserver. I wiped the box to try Xandros, and will be wanting to restore my backup. I've got two questions.

1 - Will I have to do an install then a restore so the partitions will be setup the same way they were before?

2 - What's the easiest way to can make a LiveCD either from my backup or after the restore?

airjrdn
September 5th, 2006, 02:15 PM
I attempted the restore this weekend. While it worked correctly, there were two hiccups.

1 - I applied the updates when Ubuntu told me there were some, which screwed up X, etc. That was a known issue (although not to me at the time).

2 - After the restore, all windows were on top of the applications bar (or whatever it's called) at the top of the screen. The titlebar to the window was above the top of my screen, so there was no moving the windows either.

While I know how to move them without the mouse in Windows, I couldn't do it in Linux. I read pages that suggested ALT-Left Mouse Button, but that didn't do the trick.

Psed
September 7th, 2006, 09:54 PM
I am a new user with Ubuntu 6.06. My problem is making backups. I have read thoughly, all the posts on this thread, and am having trouble understanding what I must do to backup my system.

I have a C HD with dual boot W2K and Ubuntu 6.06, and I want to back up Ubuntu to my D drive, as a total backup with no file or user exceptions. The D drive is formatted as FAT 32, with an existing backup of my W2K, and lots of other free space left over.

Can anyone advise me of a script to put in terminal to accomplish this?

Thank you,

Psed

airjrdn
September 8th, 2006, 12:28 PM
Are Windows and Linux installed on the same partition?

pufuwozu
September 8th, 2006, 12:33 PM
Thanks for this. Hopefully I'll keep back-ups of my system soon.

CGW
September 8th, 2006, 09:16 PM
I ran this backup before with no problem. But this time I had to also add "--exclude=/root/backup.tgz" to the entry. I also had the "--exclude=/backup.tgz" in there too--but for some reason I had to add the root version also.

:confused: :confused:

xyz
September 10th, 2006, 02:48 PM
Hi-
First of all, thank you for this HowTo!
The first time I used it, everything worked fine. Now what with updates and all, I want a new back up
I run the command Heliode initially posted but, for some reason, it ignores the fact that I want to exclude media which is where windonw is.

Could someone tell what to do here?
(I did include: --exclude=/media in the command line.)

Psed
September 12th, 2006, 04:04 AM
Are Windows and Linux installed on the same partition?

No, Windows 2000 in on the first 9Gig of my C drive and Linux 6.06 is on the next 9 Gig of my C drive. The remainder is for the swap file.

The drive I want to back up to has 10G of free space, set as
FAT 32.

psed](*,) ](*,)

schintgenj
September 12th, 2006, 04:55 PM
Hi-
First of all, thank you for this HowTo!
The first time I used it, everything worked fine. Now what with updates and all, I want a new back up
I run the command Heliode initially posted but, for some reason, it ignores the fact that I want to exclude media which is where windonw is.

Could someone tell what to do here?
(I did include: --exclude=/media in the command line.)

I think there is a bug in tar. If you put the "--exclude=" command before the "cvpzf" options, it works.

xyz
September 13th, 2006, 01:31 PM
I think there is a bug in tar. If you put the "--exclude=" command before the "cvpzf" options, it works.
Somewhow I couldn't figure how this could possibly work:

tar --exclude=/media cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys


root@luser:/# tar --exclude=/media cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
tar: You must specify one of the `-Acdtrux' options

I also tried to --exclude=/media/hda1 (hda1 = wind). No go.

DOD1951
September 14th, 2006, 11:22 AM
Just one other thing to exclude, unless you really want to back it up, is the /media/cdrom0. I left a dvd in the cdrom drive and backed that up as well :?

xyz
September 14th, 2006, 12:49 PM
Just one other thing to exclude, unless you really want to back it up, is the /media/cdrom0. I left a dvd in the cdrom drive and backed that up as well :?

Thanks for reminding me! It's true that this could so easily happen! ;)

xyz
September 14th, 2006, 12:55 PM
Finally solved that one! Typos are sometimes the way to finding a solution!
The original command line:

tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys
as I wrote previously, would simply not exclude windows (media/hda1).

However this command line did the jog fine:

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/media --exclude=/sys /


The difference is adding a / at the very end of the line!!

Anybody can explain why this made all the difference? Thanks.

moore.bryan
September 14th, 2006, 01:20 PM
--exclude=/media doesn't exclude /media... any ideas?

xyz
September 14th, 2006, 03:48 PM
--exclude=/media doesn't exclude /media... any ideas?

The solution is in my last post this thread on page 21! That is, it worked for me; I was able to back up excluding media. ;)

moore.bryan
September 14th, 2006, 03:51 PM
i was hoping that would be the response... i read your post, but wasn't sure it covered everything i might want to exclude. any ideas why it works?

xyz
September 14th, 2006, 04:03 PM
i was hoping that would be the response... i read your post, but wasn't sure it covered everything i might want to exclude. any ideas why it works?

Well, I sure wish I could rant and boast about it telling you...you know,man...I did this and you just have to that because of this ant that!!:)
with tons of codes!!!

The fact is it's sheer luck!! For some reason, I did a typo (/) at the end of the line!=D>
Let me know how it went. Oh boy, about the codes, maybe in a couple of decades!! Good luck.

Check this too:
http://www.psychocats.net/ubuntu/partimage (among other advantages, you can backup a partition over 4G)

moore.bryan
September 14th, 2006, 04:07 PM
sometimes it's better to be lucky than good...
;-)
thanks, again.

subiet
September 19th, 2006, 06:53 PM
one small tip, plz empty your trash folders, i forgot to do mine, and it had a 200 mb home video, so wasted that much space and time.

jchau
October 1st, 2006, 05:06 AM
I want to write the backups to DVD using cdbackup. I also want to do use tar's incremental backup feature to save storage space? Will this work?

podunk
October 3rd, 2006, 01:16 PM
That was very impressive! Very fast!

For some reason it didn't back /var even though I didn't exclude it?

I unmounted my windows drives by typing
#
in front of their entry in fstab and rebooting.

I excluded /tmp because it seemed to have my windows drive in it in a folder
gconfd-dennisx

Was that ok – or will it make the restore go bad if I ever have to?

zasf
October 3rd, 2006, 03:12 PM
i was hoping that would be the response... i read your post, but wasn't sure it covered everything i might want to exclude. any ideas why it works?
Well, I sure wish I could rant and boast about it telling you...you know,man...I did this and you just have to that because of this ant that!!:)
with tons of codes!!!


It is just a matter of tar's version 8)

Maybe we should just ask the first poster to edit his post.. people just keep asking that :wink:

calvinthomas
October 4th, 2006, 04:57 PM
I've just backed up and wondering if the file size is right because it seems small, my used space is around about 8Gb and my backup in .tgz is 2.1 GB I didn't see any errors but it seems small, is it just compressed really well or is something probably wrong?

Calv

atery
October 17th, 2006, 12:59 PM
To xyz:
I encounter a stranger problem, that is I can't exclude any folders from the command line! ...not only the media one... so strange...

xyz
October 18th, 2006, 10:52 AM
To xyz:
I encounter a stranger problem, that is I can't exclude any folders from the command line! ...not only the media one... so strange...

Hi atery,
You did do this exactly with the / at the end of the line?



sudo su
cd /
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/media --exclude=/sys /



At worst you could exclude nothing...except for /media and see if it works or try another HowTo backingup method!
Let me know...

ArsGeek
October 18th, 2006, 05:05 PM
Funny, I'm writing a howto on this right now :)

Ubuntu seems to be using GNU tar, which works a bit differently.

You need to construct your phrase like this:

sudo tar cvpzf backup.tgz --exclude="/proc/*" --exclude="/lost+found/*" --exclude="/backup.tgz" /

Rember to put your source ("/") at the end of your phrase.

Arsgeek
http://www.arsgeek.com

ebutton
October 21st, 2006, 12:45 AM
The listed tar command has a glaring error. The --exclude=xx entries must come before the target directory ("/" in this case). In other words, the / must be at the end of the command line, not before the exclude expressions.

I didn't read all 8 pages, so someone else may have pointed out this error before now.

Hopefully, no one else will waste two hours trying to figure out what was wrong! :p

Otherwise, this post was very helpful to me!

Regards,
EdB

maddbaron
October 21st, 2006, 05:09 PM
this is all like chinese to me....i dont speak chinese lol...

all i'd like to do is backup my system to a blank dvd. i have windows xp on another partition.

i dont understand the unmounting of windows...?

this is complicated...

xyz
October 22nd, 2006, 11:30 AM
The listed tar command has a glaring error. The --exclude=xx entries must come before the target directory ("/" in this case). In other words, the / must be at the end of the command line, not before the exclude expressions.

I didn't read all 8 pages, so someone else may have pointed out this error before now.

Hopefully, no one else will waste two hours trying to figure out what was wrong! :p

Otherwise, this post was very helpful to me!

Regards,
EdB

I'm not sure what you're talking about but the command line worked "as is" for me!

maddbaron...would this one seem less Chinese to you:
http://www.whiprush.org/2006/10/ahhh_backups.html

hihihi
October 25th, 2006, 11:58 AM
hello, first i want to thanks for this text as it helped me to make my first backup under linux, ubuntu.
but some weeks ago i installed ubuntu from the scratch. everything is running 1a. exeption is the backup with tar of system because it will not read --exclude command.
what is wrong? is it tar, the system, is it me?
thanks a lot,

hihihi
October 25th, 2006, 12:11 PM
its me again:
problem solved after reading upper threads:
tar backup.tgz --exclude=/blabla /
the directory to be backupped is written after exclude commands.
ciao

xyz
October 26th, 2006, 09:30 AM
its me again:
problem solved after reading upper threads:
tar backup.tgz --exclude=/blabla /
the directory to be backupped is written after exclude commands.
ciao
And once you restore, you won't forget to recreate the excluded files!
mkdir proc.....for instance.

Numenory
October 27th, 2006, 02:01 PM
A very helpful article

ric_spam
October 27th, 2006, 07:35 PM
My strategy is to use partimage to backup the whole system and then either rsync or tar to backup that which changes more often ie home directories.

In the user directories, there are a couple which I don't think need to be backed up

.beagle and .Trash

Given they are hidden, how do I properly format the --exclude clauses for either/or both tar & rsync?

I tried the ones I knew, tick, back-tick, double quote, wack with no success.

Currently on a newer install my home dir is at 600 MB, of which 300 is in .beagle.

TIA
UPDATE:

So, I got thru reading the many other pages on this topic and will draw your attention to posts #135, #150, #161 and #162. My error was not the incorrect format of the command line parse for the dot files, but rather that tar had changed.

Bad developer - no donut.

Someone asked a 'noob' question and I didn't see a reply. It was how to include the hidden or dot directories. Ans: they are included.

So while I am in the dir I want to save my backups to, /mnt/backup I ran this successfully
% tar cvpjf backup.tar.bz2 --exclude=.Trash --exclude=News --exclude=.beagle /home/me

.Trash is excluded cause I threw it away once already
.beagle - easily recreated and huge, relatively speaking
News - for Pan, and I regard usenet posts as transitory anyway.


Any other directories in /home that you might choose to not backup?


now I gotta scan back for those posts on samba 2 gig limitation ... ...

hikaricore
November 1st, 2006, 11:11 AM
Thanks to this post I archived my system only hours before destroying it with the multicrash feature of the edgy upgrade process. :D

Just saying my thanks.

aysiu
November 6th, 2006, 04:48 AM
I have a few questions about this. I use rsync to back up my /documents partition, but I want to use the method outlined in this thread for backing up my / partition.

I'm worried it will actually overwrite my /documents partition, though. Would something like this work? Also, any reason to
sudo su first instead of just using one sudo command?

I would be using this for backup:
#!/bin/bash
sudo umount /documents
sudo su
cd /
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
mount -a
exit and then this to restore:
#!/bin/bash
sudo umount /documents
sudo su
cd /
tar xvpfz backup.tgz -C /
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
mount -a
exit I'm particularly worried about this since I have some items symlinked from /documents to my /home/username folder on the / partition. Would it bork my system to have symlinks from a partition that isn't mounted yet, even if the partition is going to be remounted later?

And there's no way Ubuntu could overwrite my /documents partition if the partition is unmounted, right?

dmizer
November 7th, 2006, 03:33 AM
i can't get this sucker to exclude my media folder (where i have my server mounted) ... it keeps including all the junk from my server in my backup.

i have tried:


tar cvpzf /media/server/shared/backup/backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/media --exclude=/sys
and

tar cvpzf /media/server/backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/media/server --exclude=/sys

but still all the shared files are getting included in the tar. as you can see, i'm attempting to save the backup to my server (/media/server) so i can restore it from there when i get a new hard drive (current drive is showing signs of failing).

any way i seem to run this thing, i still get this:

/etc/idmapd.conf
/media/
/media/cdrom
/media/cdrom0/
/media/floppy
/media/floppy0/
/media/server/
which then proceeds to inculde everything on my server in the backup :(

aysiu
November 7th, 2006, 03:52 AM
I read in some other thread that if you put / last that it will work--not sure what the difference is, though.

So it'd be something like this:
sudo su
cd /media/server/shared/backup/
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/media --exclude=/sys /

hameda
November 7th, 2006, 05:13 AM
whats going on, i see all the files i wanted to exclude being included in the archive? whats going on. i am copying and pasting your commands??

i am struggling here

dmizer
November 7th, 2006, 07:10 AM
I read in some other thread that if you put / last that it will work--not sure what the difference is, though.

So it'd be something like this:
sudo su
cd /media/server/shared/backup/
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/media --exclude=/sys /

that did the trick ... thanks.

dmizer
November 7th, 2006, 04:31 PM
just restored my system. here's what i did:
backed up the entire system to my server. purchased a 60 gig hard drive to replace my ancient 6 gig hard drive that was beginning to show signs of wear.

installed the alternate server dapper on the new drive (backuped system was dapper) > copied backup file to the new hard disk > unziped as root > reboot = completely restored system in less than an hour's work (not including the walk to the parts store to purchase the new drive).

i didn't have to recreate any directories after the backup was done, and because i installed the server from scratch, i didn't have to restore grub.

only problem i've run into so far is that i had some kind of strange permissions problem related to the linux restricted modules package. i just reinstalled it and no more problem with that. man this new drive is fast! and it's very comforting not to hear loud clunking every 5 minutes or so.

jromer
November 12th, 2006, 02:53 PM
As mentioned before, I had to read quite a bit of this thread to find out that there is a typo on the first post that causes a lot of confusion (to me anyways)...

the code is shown as...

tar cvpzf backup.tgz / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys

when the "/" should be at the end of the command as follows:

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/media --exclude=/sys /

I feel this should be edited. (I'm not the first to mention this).

Thanks

OmahaVike
November 29th, 2006, 06:08 AM
here! here! to jromer's post.

i have been witness to *numerous* posts all indicating the same "slash at the end" solution. while it has been documented throughout this particular thread, i can sympathize with the posters in not wanting to read through all 24 pages. please save us the agony and edit the original post.

aysiu
November 29th, 2006, 06:16 AM
here! here! to jromer's post.

i have been witness to *numerous* posts all indicating the same "slash at the end" solution. while it has been documented throughout this particular thread, i can sympathize with the posters in not wanting to read through all 24 pages. please save us the agony and edit the original post.
Done, as best as I know. Please post right away if I didn't correct the first post properly.

shane2peru
December 5th, 2006, 03:35 PM
Can someone explain how to put this into a cron job, so that it runs regularly every 2 weeks or something like that? Can this be done? Thanks.

Shane

BTW - Great HOWTO, I have used it often, and restored from it a time or two.

OmahaVike
December 5th, 2006, 07:21 PM
thanks aysiu! very much so.

shane2peru: look in to 'crontab -e'. you'll need to do a little reading (not heavy stuff) first.

shane2peru
December 5th, 2006, 07:58 PM
shane2peru: look in to 'crontab -e'. you'll need to do a little reading (not heavy stuff) first.
Thanks, I found what I was looking for a crontab howto (http://www.ubuntuforums.org/showthread.php?t=102626&highlight=crontab+-e) I have never done this cron stuff, or crontab. I kept looking for cron, didn't know I needed crontab. Thanks.

Shane

spliskin
December 8th, 2006, 07:17 PM
many thanks for this guide!
as a complete noob to Ubuntu and Linux I found this very helpful after
compiling my programs and settings.
MHO this is one of the first things all newbies should take time to learn as it will save so much time in times of emergencies.

Again many thanks to the friendly users of this forum! I hope to learn much much more within the coming months. :)

dwblas
December 13th, 2006, 09:39 PM
I also exclude /var/cache and /var/lib/apt since it can be rebuilt via Synaptic update.

saiz66
December 15th, 2006, 11:28 PM
I have tried to restore my backup and after it was done I noticed that a program was still there that I have installed after my last backup. I thought after the restore it would restore it exactly to the way it was before. How can I restore it the way it was before because I dont want that newly installed program any more?

kimatrix
December 23rd, 2006, 05:20 PM
I have tried this method in vmware buy backuping everything and after that i deleted the whole usr folder. Ubuntu was getting crazy almost nothing worked because all the icons en things like that where gone. So i tried restoring and that worked like a charm in 2 minutes the system was back as it was everything working perfectly and afcorse all this without rebooting.

Only thing i think is **** is that you can not use increment backups with zipped files, or does someone has a solution for this?

Also it could be usefull to see what application you use the most and if they keep cache if so it could be smart to exclude those caching folders too. (it saves disk space and backuping time)

I almost forgot thank you for this simple but jet effective approach.

squrl
December 29th, 2006, 07:00 PM
This is a bunch of crap. Follow your own directions and see how far you get. copy and paste your command line and see if you get any more than errors and NO restore. I suspected as much so before applying it to my system I set up a dummy and tried it. VERIFY before you put something in front of us dummies looking for help

yebo29
January 3rd, 2007, 09:45 PM
But it's a commercial application.... :?

EXACTLY. 'Nuff said. :-D