shadowbyte
Posts: 18
Joined: Sat Apr 09, 2016 3:29 am

Backing up my large uSD card

Wed May 25, 2016 1:27 pm

A couple questions about backing up my uSD card..

1) As my cards continue to get larger, is there a way to backup my cards without backing up the empty space on the card as well? In other words, if my card is 16GB and has 11GB of free space is there a way to back it up as a <>5GB file? It might help that I'm a Linux user on my primary work station.

2) Also, if I back up to a new card using the new Raspbian backup, can I re-expand my 16GB backup to a 32GB card after I boot the 32GB card?

Thanks
Shadow

User avatar
RaTTuS
Posts: 10531
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Backing up my large uSD card

Wed May 25, 2016 1:43 pm

backup using rsync to a remote location
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Backing up my large uSD card

Wed May 25, 2016 1:53 pm

This topic has been beat to death... do some searches...

... but, this next part is new, I think. Its a neat little unix trick that can be used to backup CD images too, thumb drives of all kinds, and the cool thing is it maintains all of the right permissions and only backs up the content, because its not a 'disk image' like dd produces ! So, here it is, I'll explain it after:

First, you need to mount the SD card in your gnu+linux notebook (or what-have-you) so that you have something like /mnt/SD-card where SD-card is the root partition that you are trying to backup. I'm assuming that you know enough about gnu+linux to get that accomplished ...

Now for the trick:

Code: Select all

cd ~/backup-directory/
tar -cvf -  -C /mnt  SD-card | tar -xvf -
Please pay attention to ALL of the spaces and hypens above... they are not typos and they are ALL important.

This is what it does... it creates a tape archive stream via stdin and stdout (that's the hyphens). The -C changes to the mount directory and what is being backed up is just the SD-card root partition that is mounted there !

This little trick will place an SD-card directory in ~/backup-directory/ and will maintain recursively all subdirectories and permissions.

It does this so well that if you use the trick to backup a CD rom to your hard drive, you can actually mount that directory as a loopback device and access it the same way you would access the CD itself!

To restore the backup just reverse the process. Obviously its only going to backup the content, not the empty space.
marcus
:ugeek:

Return to “Raspbian”