View previous topic :: View next topic |
Author |
Message |
lightning n00b
Joined: 14 Nov 2007 Posts: 65
|
Posted: Mon Sep 14, 2009 11:17 am Post subject: backup |
|
|
Hi there,
Can you advice me the best backup solution for my system? I actually have two OS' xp and gentoo and I would like to have backed up all the data from entire disk and be able to quickly restore it. I am planning to perform dangerous operation that could case all the data lose, therefore I am looking for solution how to protect it and I case something false to restore everything to previous state.
I would also like to know how you guys do the backups, what tools are you using to keep everything secure. Small advice as well as useful links are very welcome. Thanks in advance folks! |
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Mon Sep 14, 2009 11:59 am Post subject: |
|
|
Hi, you should try DD.
If you have a second disk, the run :
Code: |
# dd if=/dev/source of=/dev/destination conv=noerror
|
|
|
Back to top |
|
|
honp Guru
Joined: 25 Sep 2006 Posts: 355 Location: Good old Prague, Czech rep.
|
Posted: Mon Sep 14, 2009 12:17 pm Post subject: |
|
|
I use just copy the whole fs (except /proc, /sys, ...) tar and bzip it. It allways worked for me, but to be honest, i am not really sure, that this could be done like this... |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Mon Sep 14, 2009 12:37 pm Post subject: |
|
|
honp wrote: | I use just copy the whole fs (except /proc, /sys, ...) tar and bzip it. It allways worked for me, but to be honest, i am not really sure, that this could be done like this... |
it works, just create a tar image for each partition _________________ Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein |
|
Back to top |
|
|
lightning n00b
Joined: 14 Nov 2007 Posts: 65
|
Posted: Mon Sep 14, 2009 6:39 pm Post subject: |
|
|
The thing is I don't have a second hdd, so the first advice with DD sounds good, but how to restore hdd image using for instance gentoo live cd? I have xp partition on the disk also and also would lika to have it backed up. I understand that dd tool will create image of entire disk, only thing I would like to know is how to restore it from image for instance stored in NFS share on different machine. Thanks in advance. |
|
Back to top |
|
|
DaggyStyle Watchman
Joined: 22 Mar 2006 Posts: 5909
|
Posted: Mon Sep 14, 2009 7:35 pm Post subject: |
|
|
lightning wrote: | The thing is I don't have a second hdd, so the first advice with DD sounds good, but how to restore hdd image using for instance gentoo live cd? I have xp partition on the disk also and also would lika to have it backed up. I understand that dd tool will create image of entire disk, only thing I would like to know is how to restore it from image for instance stored in NFS share on different machine. Thanks in advance. |
in order to save a 100 gigs partition you need to create a 100 gigs image even when you use only 10 gigs, with the tar, the size is the accumlated file size
better than the first option in my mind _________________ Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein |
|
Back to top |
|
|
lightning n00b
Joined: 14 Nov 2007 Posts: 65
|
Posted: Mon Sep 14, 2009 11:29 pm Post subject: |
|
|
THe disk is not too big, so I don't care about image size. Still don't know how to restore the image made by dd. |
|
Back to top |
|
|
Mike Hunt Watchman
Joined: 19 Jul 2009 Posts: 5287
|
Posted: Tue Sep 15, 2009 3:08 am Post subject: |
|
|
If you dd, then the image is an exact copy, so to restore it just reverse the dd comand
Code: | dd if=/dev/source of=/dev/destination conv=noerror |
reverse
Code: | dd if=/dev/destination of=/dev/source conv=noerror |
The thing about dd though is that your file permissions will be changed. So tar is probably a better choice because of the 'p' switch.
My favorite is rsync Code: | rsync -av /source /destination |
|
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Tue Sep 15, 2009 3:19 am Post subject: |
|
|
Mike Hunt wrote: | The thing about dd though is that your file permissions will be changed. So tar is probably a better choice because of the 'p' switch. |
Are you sure about DD, because I use DD when I need to run a Forensic investigation and only DD can be valid in front of the judge. |
|
Back to top |
|
|
Mike Hunt Watchman
Joined: 19 Jul 2009 Posts: 5287
|
Posted: Tue Sep 15, 2009 4:05 am Post subject: |
|
|
Code: | $ touch bogus_file
$ chmod +x bogus_file
$ ls -l bogus_file
-rwxr-xr-x 1 mike users 0 2009-09-15 00:03 bogus_file
$ dd if=bogus_file of=bogus_file.dd
0+0 records in
0+0 records out
0 bytes (0 B) copied, 2.2483e-05 s, 0.0 kB/s
$ ls -l bogus_file.dd
-rw-r--r-- 1 mike users 0 2009-09-15 00:04 bogus_file.dd |
|
|
Back to top |
|
|
Akkara Bodhisattva
Joined: 28 Mar 2006 Posts: 6702 Location: &akkara
|
Posted: Tue Sep 15, 2009 6:15 am Post subject: |
|
|
Mike Hunt wrote: | Code: | $ touch bogus_file
$ chmod +x bogus_file
$ ls -l bogus_file
-rwxr-xr-x 1 mike users 0 2009-09-15 00:03 bogus_file
$ dd if=bogus_file of=bogus_file.dd
0+0 records in
0+0 records out
0 bytes (0 B) copied, 2.2483e-05 s, 0.0 kB/s
$ ls -l bogus_file.dd
-rw-r--r-- 1 mike users 0 2009-09-15 00:04 bogus_file.dd |
|
Yes, if you dd a regular file.
But for backups you dd the raw device. And when that raw device is mounted, the modes and times are interpreted from its dd-restored data and the filesystem it presents is exactly the same as it was.
To see this:
Make a new filesystem in a file: Code: | dd if=/dev/zero of=filesys.img bs=1M count=16
/sbin/mkfs.ext3 -F filesys.img |
Mount it and create a file in it with a weird mode: Code: | mkdir test
mount filesys.img test -o loop
echo 'hello' >test/hi.txt
chmod 421 test/hi.txt
ls -l test/hi.txt
umount test |
Copy it with 'dd', set a different strange mode on the copy: Code: | dd if=filesys.img of=copy.img
chmod 651 copy.img
ls -l copy.img |
Mount the copy and examine the originally-made file: Code: | mount copy.img test -o loop
cat test/hi.txt
ls -l test/hi.txt
umount test |
It is the same. |
|
Back to top |
|
|
lightning n00b
Joined: 14 Nov 2007 Posts: 65
|
Posted: Tue Sep 15, 2009 6:30 am Post subject: |
|
|
According to Akkara permissions will stay in their original state, therefore this method seems to be the best for me as I want backup my xp partition (and system) on the same disk. Only two more issues worry me.
1. Can I make whole image including MBR (or separate two, one for mbr the other for the rest) and restore it?
2. If I mount NFS or SMB share to write image on it, will the DD follow it recursively or just backup the raw disk data only? |
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Tue Sep 15, 2009 12:06 pm Post subject: |
|
|
Yes, you can backup your mbr like this :
Code: |
# dd if=/dev/sda of=/mnt/backup/mbr.dd bs=512 count=1
|
|
|
Back to top |
|
|
P.Kosunen Guru
Joined: 21 Nov 2005 Posts: 309 Location: Finland
|
Posted: Tue Sep 15, 2009 4:28 pm Post subject: |
|
|
lightning wrote: | 1. Can I make whole image including MBR (or separate two, one for mbr the other for the rest) and restore it?
2. If I mount NFS or SMB share to write image on it, will the DD follow it recursively or just backup the raw disk data only? |
Code: | dd if=/dev/sda of=/mnt/nfs/sda-20090915.img |
If source (if=) is disk, mbr is included and backup is entire raw disk bit by bit. |
|
Back to top |
|
|
Mike Hunt Watchman
Joined: 19 Jul 2009 Posts: 5287
|
Posted: Tue Sep 15, 2009 4:47 pm Post subject: |
|
|
Akkara wrote: | ....It is the same. |
Yes it is, Thanks |
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Tue Sep 15, 2009 5:22 pm Post subject: |
|
|
In fact, DD copy the data by sector instead of using the file system as a reference to know what to copy |
|
Back to top |
|
|
jel Apprentice
Joined: 10 Aug 2005 Posts: 259 Location: Gothenburg
|
Posted: Wed Sep 16, 2009 11:52 pm Post subject: |
|
|
I tar the contents of /etc & /boot and some important subdirs of ~ to an external drive at irregular intervals. My ~ is too cluttered with crap, otherwise I would simply tar ~.
Code: | jel@jel-desktop ~/bak $ du -sh ~
22G /home/jel
|
I used to manage /etc with RCS, but it got messy quickly. (Maybe I should create a subversion repository and commit /etc changes to it?) _________________ # dd if=/dev/urandom of=/dev/sda bs=512 |
|
Back to top |
|
|
|