You are not logged in.

#1 2009-04-10 16:34:00

Fackamato
Member
Registered: 2006-03-31
Posts: 579

Best way to backup your partition?

What is the best way to back up a partition? /dev/sda1 is windows and sda2 is Archlinux. Say if I wanted to reformat sda2 with an new filesystem, but continue to use the exact same installation of Archlinux that I've tailored everywhere possible (I would have to change fstab of course), what would be the best way to backup all files with compression while keeping ownerships and rights? (note: speed is favoured over high compression here though, but any compression would be nice)

All advices are welcome smile

Offline

#2 2009-04-10 17:05:07

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: Best way to backup your partition?

Fackamato,

I regularly backup using 'rsync'. It has the advantage of only copying changed/new files, eventually deleting deleted
ones.

You can use a mounted NAS, or an internal partition as target. If the NAS also has 'rsync', you can also use it in client/server mode.

F.e., on a local internal partition:

rsync -av --delete --delete-excluded --exclude="/sys/**" --exclude="/proc/** " --exclude="/backup/"  /   /backup

/backup being a mounted backup partition

'rsync' is most useful if you regularly backup, but has some interest also in one shot copies: if for some reason
the copy fails, f. e. out of space, when you solve the problem and restart, it will only copy what it needs to.

For your particular case, if you have a spare internal partition with enough space (or make one fiddling with gparted),
you could:

mount /dev/sda3 /backup (sda3 being your new partition)
rsync -av --delete --delete-excluded --exclude="/sys/**" --exclude="/proc/** " --exclude="/backup/"  /   /backup

Change /etc/fstab on sda3.

Add the necessary lines to menu.lst (I suppose you are using Grub) to boot from sda3.

So you can test that everything works before destroying sda2.

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

#3 2009-04-10 17:31:26

Fackamato
Member
Registered: 2006-03-31
Posts: 579

Re: Best way to backup your partition?

Thanks!

I'm going to back up to an external USB harddrive, so I'd have to use initramfs (or kernel with usb modules compiled in) to be able to boot from it, but your method seems solid.

I'll prepare a USB stick now in case of rescue and backup later.

Cheers smile

Offline

#4 2009-04-10 18:17:11

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: Best way to backup your partition?

Slightly off-topic, I also use now and then a USB disk with ARCH on it.
What confuses me, are the device names in menu.lst.

They are also different depending if you boot from your hard disk, or, if your BIOS allows it, boot directly
from the USB disk (and have Grub installed on it as well).

For example, booting directly from my USB disk, I have the following in the USB disk menu.lst:

title  Arch Linux MiniLacie root=/dev/sdb1 (hd0,0)
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/sdb1 ro vga=773
initrd /boot/kernel26.img

Now, I found this by trial and error, but looks strange. hd(0,0) should be /dev/sda1, or?

It work for me.

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

#5 2009-04-10 18:25:29

Fackamato
Member
Registered: 2006-03-31
Posts: 579

Re: Best way to backup your partition?

Mektub wrote:

Slightly off-topic, I also use now and then a USB disk with ARCH on it.
What confuses me, are the device names in menu.lst.

They are also different depending if you boot from your hard disk, or, if your BIOS allows it, boot directly
from the USB disk (and have Grub installed on it as well).

For example, booting directly from my USB disk, I have the following in the USB disk menu.lst:

title  Arch Linux MiniLacie root=/dev/sdb1 (hd0,0)
root   (hd0,0)
kernel /boot/vmlinuz26 root=/dev/sdb1 ro vga=773
initrd /boot/kernel26.img

Now, I found this by trial and error, but looks strange. hd(0,0) should be /dev/sda1, or?

It work for me.

Mektub

Use persistent names, like UDEV or by label.

# (4) Arch Linux patchy
title  Arch Linux patchy
root   (hd0,1)
kernel /boot/vmlinuz26-patchy root=/dev/disk/by-uuid/3cdd02eb-7cdf-4772-bd6a-ed4a791a0e0e ro elevator=deadline quiet resume=swap:/dev/sda2:0x728000 fastboot vga=868
savedefault

Offline

#6 2009-04-11 11:16:24

dschrute
Member
From: NJ, USA
Registered: 2007-04-09
Posts: 183

Re: Best way to backup your partition?

Now, I found this by trial and error, but looks strange. hd(0,0) should be /dev/sda1, or?

Grub doesn't distinguish between different types of disks ( IDE, SCSI, RAID ).  It just sees whatever drives your system does, and calls them HD(0), HD(1), HD(2), etc...

Offline

#7 2009-04-11 11:58:31

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: Best way to backup your partition?

dschrute wrote:

Now, I found this by trial and error, but looks strange. hd(0,0) should be /dev/sda1, or?

Grub doesn't distinguish between different types of disks ( IDE, SCSI, RAID ).  It just sees whatever drives your system does, and calls them HD(0), HD(1), HD(2), etc...

And I think that hd0 is always the medium that grub is loaded from.

Offline

#8 2009-04-11 20:12:35

Fackamato
Member
Registered: 2006-03-31
Posts: 579

Re: Best way to backup your partition?

Say, I've only a NTFS partition to back up to. That doesn't preserve Linux permissions (it's a experimental feature in ntfs-3g cvs/svn I think) so backing up to this NTFS partition would not be very good I guess (all permissions would be wrong).

I was thinking of creating an image file (dd if=/dev/zero of=/ntfs/linuxbackup.img bs=1M size=10240) and just creating an ext2 partition on it. Then mount that, and rsync to it.

Any opinions on this?

Offline

#9 2009-04-11 21:43:43

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: Best way to backup your partition?

Fackamato wrote:

I was thinking of creating an image file (dd if=/dev/zero of=/ntfs/linuxbackup.img bs=1M size=10240) and just creating an ext2 partition on it. Then mount that, and rsync to it.

Any opinions on this?

That's the way to go IMO.

Offline

#10 2009-04-11 21:47:12

Fackamato
Member
Registered: 2006-03-31
Posts: 579

Re: Best way to backup your partition?

bender02 wrote:
Fackamato wrote:

I was thinking of creating an image file (dd if=/dev/zero of=/ntfs/linuxbackup.img bs=1M size=10240) and just creating an ext2 partition on it. Then mount that, and rsync to it.

Any opinions on this?

That's the way to go IMO.

I was going to do that but then I realized I'd have the overhead of ext2 + ntfs-3g (ugh!), so I resized the NTFS partition and created an ext4 partition on the remaining space instead.

Thanks for all the help smile

Offline

#11 2009-04-12 06:01:07

adamlau
Member
Registered: 2009-01-30
Posts: 418

Re: Best way to backup your partition?

I usually use Clonezilla to image the partition in question onto an available HDD.


Arch Linux + sway
Debian Testing + GNOME/sway
NetBSD 64-bit + Xfce

Offline

#12 2009-04-12 07:15:57

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: Best way to backup your partition?

Fackamato wrote:

I was going to do that but then I realized I'd have the overhead of ext2 + ntfs-3g (ugh!), so I resized the NTFS partition and created an ext4 partition on the remaining space instead.

Thanks for all the help smile

Sure smile Well that changes the original conditions (suppose that I only have a NTFS drive to back it up to...) smile but yes, if you can do this than it's better.
adamlau also has a good suggestion, use clonezilla or parted magic of partclone or something like that, but the disadvantage is that there's no way to do an incremental update with a partition image.

Offline

#13 2009-04-12 07:21:24

Fackamato
Member
Registered: 2006-03-31
Posts: 579

Re: Best way to backup your partition?

I just reformatted and rsynced back, everything works like a charm! Thanks again all smile

( see http://bbs.archlinux.org/viewtopic.php?pid=533466 & http://www.ocztechnologyforum.com/forum … tcount=129 )

Offline

Board footer

Powered by FluxBB