LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-05-2010, 11:40 AM   #1
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 20.04 LTS
Posts: 304

Rep: Reputation: 21
Backing up system with two HDs


I have a Seagate USB drive that I'd like to use as a backup drive for my home system with two drives. One drive contains /home and /root, the other contains /var. I've read about a lot of different software for backups but I'm not really sure which one would be the best for this. I want to be able to use this backup to restore the system just in case something happens. What would be the best software to use for this? I'd like something that will basically clone the system I assume since I'd like it to not only copy the system structure but also symlinks.

Chris
 
Old 09-05-2010, 12:31 PM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Greetingz!

For one-time, full system backups (especially on Windows machines), I usually do the following;

Code:
dd if=/dev/sda bs=1M | bzip2 -9| ssh USERNAME@remotehost "cat - > drive.img.bz2"
Note: "sda" is a whole disk. You could do a partition (sda1, sda2, etc) or even a logical volume (/dev/vg0/lv01)

As you have several partitions (/home, /root, /var) across multiple disks, you may want to just do the device mount points (be they something like /dev/sda1, /dev/sdb1, etc).
Keep in mind the following command can be adapted to disk-to-disk (rather than over-the-network);

Code:
dd if=/dev/sda bs=1M | bzip2 -9 > drive.img.bz2
This will copy everything, block-by-block, exactly as it appears on the filesystem. Keep in mind that there's two downsides to this method;
1) Even 'empty space' is copied (another reason we use bzip2)
2) To restore a single file requires mounting-up the compressed filesystem.

To Restore the Whole Filesystem
(after using the command above)

Code:
bzip2 -dk drive.img.bz2 | dd of=/dev/sda
For further reading, check out *THE* LQ "dd" thread. For additional information on bzip2, check over here. As always, I strongly recommend reading the man pages, too!
 
1 members found this post helpful.
Old 09-05-2010, 03:52 PM   #3
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 20.04 LTS
Posts: 304

Original Poster
Rep: Reputation: 21
Thanks! This is very helpful. I've taken a quick look at the links you provided will go more in depth later when I'm ready to do this. I assume that dd will backup /dev/sda1 (home)for instance to /dev/sdc1 (FreeAgent USB Drive) or will the backup have to be copied over to it after its written? Would I have to boot from a 'rescue disk' ie..KNOPPIX or can it be done while the system is active? I'll print off the dd manpage here in a few and give it a good read.

Thanks for the very helpful post and the quick reply.

Chris
 
Old 09-05-2010, 04:48 PM   #4
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Quote:
Originally Posted by Toadman View Post
I assume that dd will backup /dev/sda1 (home)for instance to /dev/sdc1 (FreeAgent USB Drive) or will the backup have to be copied over to it after its written?
This command;
Code:
dd if=/dev/sda bs=1M | bzip2 -9 > drive.img.bz2
Will create the .img.bz2 file in whatever directory you happen to be in.
If you want to create it in a certain directory, I would suggest the following;
Code:
dd if=/dev/sda bs=1M | bzip2 -9 > /path/to/dir/drive.img.bz2
Quote:
Originally Posted by Toadman View Post
Would I have to boot from a 'rescue disk' ie..KNOPPIX or can it be done while the system is active?
You can run the aforementioned "dd & bzip2" command while the system is "hot" (online). No need to boot off a Linux Live CD (unless you're doing a restore, then I would strongly recommend you do that).
The only time I use a Linux Live CD on a Linux system is when I'm doing a restore (or backing-up MSFT-based operating systems)

Quote:
Originally Posted by Toadman View Post
Thanks for the very helpful post and the quick reply.

Chris
You're very welcome. Good Luck!
 
1 members found this post helpful.
Old 09-05-2010, 07:34 PM   #5
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 20.04 LTS
Posts: 304

Original Poster
Rep: Reputation: 21
Thank you, one last question,or maybe two I think. Will the file names always be drive.img.bz2 or can they be named something else? Since I'll be doing 2 drives can't have two files with the same name. Can dd be used to make incrimental backups of for instance changed files since the last backup? For instance if a newer version of wget is installed or is a complete backup required?
 
Old 09-05-2010, 08:04 PM   #6
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Quote:
Originally Posted by Toadman View Post
Will the file names always be drive.img.bz2 or can they be named something else? Since I'll be doing 2 drives can't have two files with the same name.
With the command;
Code:
dd if=/dev/sda bs=1M | bzip2 -9 > /path/to/dir/drive.img.bz2
You can replace "/path/to/dir/drive.img.bz2" with whatever you want. Just as long as it's a valid path, and a filename that isn't currently in use.

If you wanted to throw that command in a script, I would suggest something like this;
Code:
dd if=/dev/sda bs=1M | bzip2 -9 > /path/to/dir/backup_image-`date +%Y_%m_%d-%H%`.img.bz2
Which would result in an output file named "backup_image-2010_09_05-1750.img.bz2" in a directory (that should exist beforehand) named "/path/to/dir".
NOTE: the 'backtick' character (a reverse aphostropy) wraps the "date" command, causing a shell (such as bash) to run *that* command first)

Quote:
Originally Posted by Toadman View Post
Can dd be used to make incrimental backups of for instance changed files since the last backup? For instance if a newer version of wget is installed or is a complete backup required?
The "dd" command is a block-level command, and works 'underneath' files. As such, it doesn't understand complex things like time/date stamps, directories, filesystem types or even which Operating System is/was using the disk.

So, no, with this method, it's the whole enchilada, every byte (even the empty ones). For example; Have a 1GB filesystem? Then an uncompressed (i.e: "not using bzip2") image file will be exactly 1GB.

If you want incremental backups, than you're going to have to start looking at an actual application, rather than a few commands strung together with some clever shell usage. (Keep in mind though, this sort of thing is good for weekly/monthly backups, especially ones that go offsite)

For something that can do incremental and/or cumulative backups, as well as full backups, you might want to consider some of these. Note that not all of them are going to be OpenSource/Free software.

Happy Backing-up!

P.S: Note that you do NOT have a "backup solution" until you've properly done a restore test!

Last edited by xeleema; 09-05-2010 at 08:08 PM.
 
  


Reply



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

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backing up an entire system brokenpromises Linux - Software 6 12-12-2007 06:45 AM
Backing up system to DVD Skyguy Linux - Newbie 4 07-31-2007 01:04 PM
Backing up your system? alime Ubuntu 2 05-18-2005 09:06 PM
7 U-ATA HDs and 1 SATA - how add to system? jago25_98 Linux - Hardware 1 12-05-2004 09:50 AM
Backing up the whole system... koyi Linux - General 12 10-07-2003 06:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:02 PM.

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