Backup

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
dd if=/dev/sdb of=/media/disk/image.dd conv=sync,noerror

This was from a thread here. I want to backup my fresh installation in case something goes wrong :cool:. Can anyone confirm if this is a good way of doing a full backup and if it is the correct command line? Can i find my sdb (backup) disk from the Debian businesscard.iso rescue mode?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It'll work, but the image it creates will be the size of the entire disk instead of just the data on it.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
dd if=/dev/sdb of=/media/disk/image.dd

This seems a better option. If it's the conv=sync option that will take up space.

I can still spare 30GB on to my backup/file disk, since there is mostly junk (movies and songs) in there, so i'll give it a try.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
No, that won't affect the size of the image because dd doesn't understand filesystems. It'll still take up the exact same amount of data as the entire disk.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
I just found out that i could not mount sda and sdb from the shell of the installer.

Must do some reading on fstab.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You should be able to mount them just fine, however /dev/sdX is the entire disk so unless you wrote a filesystem to an unpartitioned disk that won't work. You need to mount /dev/sdXY where Y is the partition number.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
I did try again, but could not mount sdax and sdbx. I get not such file or directory, or invalid argument errors. I edit /etc/fstab, and doing something wrong there it seems.

I also read the man fstab and see whats written in the fstab of my laptop. I do not mind reinstalling but it takes me about 6-7 hours due to my 0.5Mb connection. I will try again, but later on.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
The fstab is only necessary if you want it to be mounted on bootup or don't want to specify options every time. Just typing 'mount -t somefs /dev/sdb1 /mnt/blah' should work as long as /dev/sdb1 and /mnt/blah both exist and you have the appropriate filesystem driver available.
 

lxskllr

No Lifer
Nov 30, 2004
57,931
8,190
126
I don't want to distract you from your current project, but Clonezilla will easily back your stuff up. I think you should learn to do it in-system(as should I), but that would be a good fallback plan if you absolutely can't get it working. As a bonus, it'll also work for Windows systems, so once you have the cd, you can use it for multiple things.
 

Gooberlx2

Lifer
May 4, 2001
15,381
6
91
Yeah clonezilla is a better option.

Still, out of curiosity, couldn't you gzip the dd image and reclaim all that space, assuming the unused space on the drive was actually all 0's?
 

lxskllr

No Lifer
Nov 30, 2004
57,931
8,190
126
Yeah clonezilla is a better option.

I don't know about better. It's more immediately accessible, but doing things "in-house" is more elegant, and you can employ creative scripting tricks to automate the process.

I need to learn how to backup my systems also. I haven't bothered as of yet due to lack of backup media, and not having too much of importance on my Linux boxes, but it's near the top of my list for things to do :^)

Edit:
Removed thumbs down icon. Not sure how that got in there. I'm not that against Clonezilla :^D
 
Last edited:

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Yeah clonezilla is a better option.

Still, out of curiosity, couldn't you gzip the dd image and reclaim all that space, assuming the unused space on the drive was actually all 0's?

Chances are the space won't be 0s or even a consistent unless you're using secure delete software that overwrites free space with some sort of pattern.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
About the fstab, i did some reading and your post Nothinman, says it clearly. I was wrong on trying to edit the file for no reason.I will also read the mount manual well to understand it enough (things like -x options are not clear to me as a novice user to the cli).

Clonezilla if i understood well, must be a distro (or program) for backup purposes. I wouldn't mind trying that but i prefer to start learning the cli and work my way through a simple bootdisk and the whatever needed commands (programs). This is also one of the reasons i went Debian instead of Ubuntu (Debian seems harder and Ubuntu easy like Windows, if i can say that). Also i stay away of Windows, i don't think i need them for anything. Even though i miss gaming, and i will give a try to lglive even though my graphic card sucks.

And i was thinking of compressing the image, which should make it around 5GB or so. If i manage to do that, i will let you know if it compresses or not.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
One more thing guys. I was reading yesterday at Debian documentation that you can backup with cp as well as dd. Any benefits of using one or the other?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
There are lots of ways to backup things, cp is just the copy command. I wouldn't recommend it because it won't handle symlinks, hardlinks, etc properly. It would be much better to use tar or cpio if you want file level backups.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
During installation i created sda1/boot and sda2/(root). Using the mount command in busybox, mount -t ext4 /dev/sda1 /boot , nothing happened. Using, mount -t /dev/sda1 / , it found a file system. This also happened at sdb1 (backup/home/file disk). I could not mount the directories (sda1 /boot and sdb1 /home) i have in the disks. Mounting sda2 was okay i think. I tried to dd but gave me an error on writing to sdb1 (no such file or directory, unable to find directory, unable to create directory, iirc).
Unmounting the disks was giving me a, device or resource busy . ls did not give me any files, and i could not cd to sda or sdb. I can only guess that mounting the disks was not done properly.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
From busybox, mounting /sdbx gave me a 'can't find /dev/sdbx in fstab. Which is why i tried to edit the file. The Debian documents info says that you do not need to mount the disk. I finally made a partition the size of the disk and typed , dd if=/dev/sda of=/dev/sdb2 , making a copy of the whole disk.

In gparted it shows as an unknown file system. but i hope it was written properly. I guess there is no way to compress that. I have plenty of room to spare so i did not mind. If i can keep the system running for a year and need the space i will delete it.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You especially don't want to mount it before doing a copy because it can cause the copy to be corrupted from filesystem caching.

If you just type 'mount /dev/sda' or 'mount /mnt/blah' it'll look in /etc/fstab for the rest of the information because the command is incomplete.

Using dd to copy /dev/sda to /dev/sdb2 copied the entire disk of /dev/sda means you got the literal entire disk, from byte 0 of the MBR to the end. So all partitions and everything to a partition on another disk so it makes sense that gparted would be confused.
 

ArisVer

Golden Member
Mar 6, 2011
1,345
32
91
The command at busybox was,
mount -t ext4 /dev/sdb2 /back
and it was giving me error. /back being the label of the filesystem, and i maybe wrong here. On Nautilus it was showing as partition 'back'. I also tried
mount -t ext4 /dev/sdb2 /
and still got the same error.

In fstab, the second option for the mount point is where i make mistakes, i think. I am confusing the labeling of the partitions with the mount point. I also tried /back and / in the second option.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
The second argument is the target directory in which to mount the filesystem, if /back doesn't exist then it will fail. And mounting something over top of / will likely cause all sorts of problems because / is the root of whatever system is currently running.

Filesystem labels are just more convenient ways of referencing a volume, i.e. /dev/disks/by-label/back, so you don't have to worry about the actual device name. They have no bearing on the mount point.