Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
backup
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
lightning
n00b
n00b


Joined: 14 Nov 2007
Posts: 65

PostPosted: Mon Sep 14, 2009 11:17 am    Post subject: backup Reply with quote

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
View user's profile Send private message
d2_racing
Bodhisattva
Bodhisattva


Joined: 25 Apr 2005
Posts: 13047
Location: Ste-Foy,Canada

PostPosted: Mon Sep 14, 2009 11:59 am    Post subject: Reply with quote

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
View user's profile Send private message
honp
Guru
Guru


Joined: 25 Sep 2006
Posts: 355
Location: Good old Prague, Czech rep.

PostPosted: Mon Sep 14, 2009 12:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Mon Sep 14, 2009 12:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
lightning
n00b
n00b


Joined: 14 Nov 2007
Posts: 65

PostPosted: Mon Sep 14, 2009 6:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5909

PostPosted: Mon Sep 14, 2009 7:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
lightning
n00b
n00b


Joined: 14 Nov 2007
Posts: 65

PostPosted: Mon Sep 14, 2009 11:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Tue Sep 15, 2009 3:08 am    Post subject: Reply with quote

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
View user's profile Send private message
d2_racing
Bodhisattva
Bodhisattva


Joined: 25 Apr 2005
Posts: 13047
Location: Ste-Foy,Canada

PostPosted: Tue Sep 15, 2009 3:19 am    Post subject: Reply with quote

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
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Tue Sep 15, 2009 4:05 am    Post subject: Reply with quote

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
View user's profile Send private message
Akkara
Bodhisattva
Bodhisattva


Joined: 28 Mar 2006
Posts: 6702
Location: &akkara

PostPosted: Tue Sep 15, 2009 6:15 am    Post subject: Reply with quote

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
View user's profile Send private message
lightning
n00b
n00b


Joined: 14 Nov 2007
Posts: 65

PostPosted: Tue Sep 15, 2009 6:30 am    Post subject: Reply with quote

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
View user's profile Send private message
d2_racing
Bodhisattva
Bodhisattva


Joined: 25 Apr 2005
Posts: 13047
Location: Ste-Foy,Canada

PostPosted: Tue Sep 15, 2009 12:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
P.Kosunen
Guru
Guru


Joined: 21 Nov 2005
Posts: 309
Location: Finland

PostPosted: Tue Sep 15, 2009 4:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Mike Hunt
Watchman
Watchman


Joined: 19 Jul 2009
Posts: 5287

PostPosted: Tue Sep 15, 2009 4:47 pm    Post subject: Reply with quote

Akkara wrote:
....It is the same.


Yes it is, Thanks :)
Back to top
View user's profile Send private message
d2_racing
Bodhisattva
Bodhisattva


Joined: 25 Apr 2005
Posts: 13047
Location: Ste-Foy,Canada

PostPosted: Tue Sep 15, 2009 5:22 pm    Post subject: Reply with quote

In fact, DD copy the data by sector instead of using the file system as a reference to know what to copy :P
Back to top
View user's profile Send private message
jel
Apprentice
Apprentice


Joined: 10 Aug 2005
Posts: 259
Location: Gothenburg

PostPosted: Wed Sep 16, 2009 11:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum