SHiLLySiT
Posts: 10
Joined: Sat Aug 15, 2015 8:05 pm

Backup RPI that boots from an external HD

Sat Aug 15, 2015 8:23 pm

Hey all! I recently purchased an RPI about 3 months ago and its been happily sitting on a shelf taking care of automated backups from my other Windows systems. I moved the RPI's filesystem over to an external HD to extend the lifetime of the SD card. However, I used a small (and quite old) 500GB HD that I'd now like to upgrade to a 2TB that I've just purchased. What is the best way to clone the HD? Silly me thought I could plug the HD into my Windows machine and copy the files!

fruitoftheloom
Posts: 20769
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 8:45 am

SHiLLySiT wrote:Hey all! I recently purchased an RPI about 3 months ago and its been happily sitting on a shelf taking care of automated backups from my other Windows systems. I moved the RPI's filesystem over to an external HD to extend the lifetime of the SD card. However, I used a small (and quite old) 500GB HD that I'd now like to upgrade to a 2TB that I've just purchased. What is the best way to clone the HD? Silly me thought I could plug the HD into my Windows machine and copy the files!
http://www.debianhelp.co.uk/ddcommand.htm
Retired disgracefully.....

fruit-uk
Posts: 609
Joined: Wed Aug 06, 2014 4:19 pm
Location: Suffolk, UK

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 9:27 am

Or format the drive and then use rsync from old to new

SHiLLySiT
Posts: 10
Joined: Sat Aug 15, 2015 8:05 pm

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 2:36 pm

fruitoftheloom wrote:
SHiLLySiT wrote:Hey all! I recently purchased an RPI about 3 months ago and its been happily sitting on a shelf taking care of automated backups from my other Windows systems. I moved the RPI's filesystem over to an external HD to extend the lifetime of the SD card. However, I used a small (and quite old) 500GB HD that I'd now like to upgrade to a 2TB that I've just purchased. What is the best way to clone the HD? Silly me thought I could plug the HD into my Windows machine and copy the files!
http://www.debianhelp.co.uk/ddcommand.htm
The webpage says "It will only work on disks that are exactly the same in disk geometry, meaning they have to the same model from the same brand". My new hard drive is a completely different model and brand. Sounds like I should go with fruit-uk's suggestion and use rsync?

RobHenry
Posts: 452
Joined: Fri Sep 21, 2012 9:04 pm
Location: UK

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 3:07 pm

dd would be a terrible choice since it copies the entire disk, including all unused space, and you would then have to resize the partition and file system. rsync would be a better choice, although straight forward cp would also work if both devices are attached directly to the pi.

SHiLLySiT
Posts: 10
Joined: Sat Aug 15, 2015 8:05 pm

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 4:51 pm

So I opted to use rsync, but it doesn't seem to be working:

Code: Select all

[email protected] ~ $ rsync -vhr /dev/sda1 /dev/sdb1
sending incremental file list
skipping non-regular file "sda1"

sent 27 bytes  received 12 bytes  78.00 bytes/sec
total size is 0  speedup is 0.00
[email protected] ~ $
What am I doing wrong?

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 4:57 pm

You need to mount sda1 and since sdb1 is already mounted, copy /

Be sure to make Rsync skip special files and stay on the same file system.

Then use Rsync to copy from the mount points.

And make sure that you partition sdb correctly. You should copy /boot to sdb1 and / to sdb2
There are 10 types of people: those who understand binary and those who don't.

User avatar
rpdom
Posts: 15238
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 5:05 pm

Rsync works at the file/filesystem level, not the device level.

You need to mount the filesystems somewhere, then run rsync to copy the contents.

Code: Select all

mkdir /media/sda1
mkdir /media/sdb1
mount -t ext4 /dev/sda1 /media/sda1
mount -t ext4 /dev/sdb1 /media/sdb1
rsync -av /media/sda1/ /media/sdb1
# Takes a while...
umount /media/sda1
umount /media/sdb1
(All run as root or with sudo, of course)
edit: kusti beat me to it :)

SHiLLySiT
Posts: 10
Joined: Sat Aug 15, 2015 8:05 pm

Re: Backup RPI that boots from an external HD

Sun Aug 16, 2015 7:09 pm

Fantastic, that worked perfectly! Thanks guys.

Return to “Beginners”