ravenwarsong
Posts: 16
Joined: Fri Dec 01, 2017 6:58 am

backup

Thu Apr 05, 2018 11:10 pm

I want to backup the pi but it has 2 Partions a fat16 for boot and a ext4.

What would be good to back up both Partions ? Clonezilla? Gparted?

I have a NAT I would love to back it up to that im not that good yet as it runs headless and I have to ssh in

bertlea
Posts: 274
Joined: Wed Dec 07, 2016 6:33 am
Location: Hong Kong

Re: backup

Fri Apr 06, 2018 2:25 am

You can simply backup the whole SD card. I use ImageWriter (Win32DiskImager) to copy the SD card to a “img” file on my PC’s HDD. Notes, you need to shutdown the pi and take out the SD card for this backup process.

I am sure there are other tools that you can backup the system without shutting down the Pi, but I never tried these yet.

ejolson
Posts: 3225
Joined: Tue Mar 18, 2014 11:47 am

Re: backup

Fri Apr 06, 2018 2:40 am

ravenwarsong wrote:
Thu Apr 05, 2018 11:10 pm
I want to backup the pi but it has 2 Partions a fat16 for boot and a ext4.

What would be good to back up both Partions ? Clonezilla? Gparted?

I have a NAT I would love to back it up to that im not that good yet as it runs headless and I have to ssh in
The FAT partition is the same on all Pi computers, not frequently modified and doesn't contain any user data.

Backup can serve two purposes: preserve user data or preserve operating system configuration. For me the user data is most important. In the event of a failure, I usually reinstall the operating system anyway. In either case, it can work well to use the program rsync to copy the required files to a backup server or an external hard disk. I would further recommend using btrfs on the backup server or the external hard disk so you can maintain historical versions of previous backups over time through filesystem snap shots. This is important. A good backup scheme is more than a copy, but a sequence of copies which reflect how files have changed over time.

ravenwarsong
Posts: 16
Joined: Fri Dec 01, 2017 6:58 am

Re: backup

Fri Apr 06, 2018 3:12 am

bertlea wrote:
Fri Apr 06, 2018 2:25 am
You can simply backup the whole SD card. I use ImageWriter (Win32DiskImager) to copy the SD card to a “img” file on my PC’s HDD. Notes, you need to shutdown the pi and take out the SD card for this backup process.

I am sure there are other tools that you can backup the system without shutting down the Pi, but I never tried these yet.

Win32DiskImager in windows will only read 1 partition at a time. I can chose that boot partition or data not both.

I need a raw read of the hole sd card

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

Re: backup

Fri Apr 06, 2018 5:01 am

ravenwarsong wrote:
Fri Apr 06, 2018 3:12 am
Win32DiskImager in windows will only read 1 partition at a time. I can chose that boot partition or data not both.
If you select the boot partition it should backup the whole card.

But for backups I recommend using the SD Card Copier in Raspbian, which can backup your running system to another SD card (in a USB adaptor). It also resizes the data to fit on the new card (which Win32DiskImager can't do). This is important because SD cards vary as to their actual usable capacity. The stated capacity is only an approximation. You may find you but two "identical" cards and they have a slightly different capacity.

ravenwarsong
Posts: 16
Joined: Fri Dec 01, 2017 6:58 am

Re: backup

Fri Apr 06, 2018 5:11 am

Thanks but that looks like it will only run on the GUI I run headless no GUI. Sounds like it would work

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: backup

Fri Apr 06, 2018 5:23 am

rpdom wrote:
Fri Apr 06, 2018 5:01 am
ravenwarsong wrote:
Fri Apr 06, 2018 3:12 am
Win32DiskImager in windows will only read 1 partition at a time. I can chose that boot partition or data not both.
If you select the boot partition it should backup the whole card.
possibly @ravenwarsong talk about
Windows 10, version 1607 (also known as the Anniversary Update)
( so it can read all partitions )
and there possibly can NOT select the DRIVE only?
also it is not reported if win32diskimager-1.0.0-install.exe was used ( or 0.7 )
anyhow both might be too old, would be good to know about that new image tools, with download links and pictures..
what work on ALL windows versions.

@rpdom there can be reasons where image files are required ( compared to a "backup SD card" with the loved SD Card copier tool ), like internet file transfer ( very difficult with a SD card )

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

Re: backup

Fri Apr 06, 2018 5:40 am

KLL wrote:
Fri Apr 06, 2018 5:23 am
@rpdom there can be reasons where image files are required ( compared to a "backup SD card" with the loved SD Card copier tool ), like internet file transfer ( very difficult with a SD card )
Yes, and Win32DiskImager is a bad way of making them. It images all the unused space.

ravenwarsong
Posts: 16
Joined: Fri Dec 01, 2017 6:58 am

Re: backup

Fri Apr 06, 2018 5:49 am

HDD Raw Copy Tool seems to work better it sees all the partions and it compresses the image all so. Thanks

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: backup

Fri Apr 06, 2018 6:13 am

ravenwarsong wrote:
Fri Apr 06, 2018 5:49 am
HDD Raw Copy Tool seems to work better it sees all the partions and it compresses the image all so. Thanks
from ?
___ hdd_raw_copy_tool.en.downloadastro.com/
get a virus warning by AVG
hdd_raw_copy_tool_3758211359.exe deleted
___________________________________________________
rpdom wrote:
Fri Apr 06, 2018 5:01 am
But for backups I recommend using the SD Card Copier in Raspbian, which can backup your running system to another SD card (in a USB adaptor). It also resizes the data to fit on the new card (which Win32DiskImager can't do). This is important because SD cards vary as to their actual usable capacity. The stated capacity is only an approximation. You may find you but two "identical" cards and they have a slightly different capacity.
yes that makes it GOOD
still note a funny story from yesterday:
i setup NOOBS PINN / 8GB SD card /
install RASPBIAN & RASPBIAN Lite
update and customized both.

systems worked but RASPBIAN had no future because that partition was nearly full.
so i used SD Card copier tool and made a 16GB SD Card with it.
hmm. the partition for RASPBIAN lite was very big!

i cleaned both SD cards.
___________________________________________________
rpdom wrote:
Fri Apr 06, 2018 5:40 am
and Win32DiskImager is a bad way of making them. It images all the unused space.
well yes, and as it is all about this here:
pls. teach us
-a- you have a RASPBIAN desktop full updated on SD card running in RPI
-b- you have a ( clean) USB stick
how to create a image file ( backup from running system ( if not possible from card reader )) from within RASPBIAN?
what later can be used by any PC / etcher to burn other SD cards.

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

Re: backup

Fri Apr 06, 2018 6:19 am

KLL wrote:
Fri Apr 06, 2018 6:13 am
pls. teach us
-a- you have a RASPBIAN desktop full updated on SD card running in RPI
-b- you have a ( clean) USB stick
how to create a image file ( backup from running system ( if not possible from card reader )) from within RASPBIAN?
what later can be used by any PC / etcher to burn other SD cards.
Actually, I suspect a fairly simple mod to the SD Card Copier could do this. If I get time I may have a look.

RonR
Posts: 411
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: backup

Fri Apr 06, 2018 7:39 am

ravenwarsong wrote:
Thu Apr 05, 2018 11:10 pm
I want to backup the pi but it has 2 Partions a fat16 for boot and a ext4.

What would be good to back up both Partions ? Clonezilla? Gparted?

I have a NAT I would love to back it up to that im not that good yet as it runs headless and I have to ssh in
image-backup (download/file.php?id=19918) will make a full backup of your running system and then allow you to make incremental backups to the created image file. The resulting image file can be written to a new SD card (or USB device) using the normal tools (Etcher, etc.).

Running image-backup with no parameters will create a full backup. To create the smallest image, specify an image size of 0 to determine the minimum size. If you plan to incrementally update it, use a considerably larger size to allow for additional growth. Do NOT create the backup image file on the running SD card (use a flash drive, Windows share, NAS, etc. for the destination).

Running image-backup with a parameter of an existing image filename will incrementally update that image file.

I run a cron job that does an incremental update at 4 am daily so I've always got a current backup.

bertlea
Posts: 274
Joined: Wed Dec 07, 2016 6:33 am
Location: Hong Kong

Re: backup

Fri Apr 06, 2018 8:48 am

The "image-backup" script RonR provided looks like a great solution comparing to what I am using. I have a few questions:

1. The script need to be run as root? I.e. run it with “sudo”?
2. It will only backup the system (and all files) on the SD card, not other USB drive attached to right?
3. The target drive shall not in FAT32 format as the image file may be better than 4G right? So it must be a drive in ext-4?
4. Can the target drive / folder be a network shared samba folder? i.e. I can backup to my Windows HDD via shared folder right?
5. We can trust that script is safe as the link is form this forums’ download link right? I do not have the knowledge to understand fully this bash script.... :(

gkaiseril
Posts: 627
Joined: Mon Aug 08, 2016 9:27 pm
Location: Chicago, IL

Re: backup

Fri Apr 06, 2018 2:32 pm

ravenwarsong wrote:
Fri Apr 06, 2018 5:11 am
Thanks but that looks like it will only run on the GUI I run headless no GUI. Sounds like it would work
You can use the piclone command in the CLI to perform the same task using a card reader and SD card.

Having run both, it looks like SD copy uses piclone.
f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: backup

Fri Apr 06, 2018 3:11 pm

gkaiseril wrote:
Fri Apr 06, 2018 2:32 pm
ravenwarsong wrote:
Fri Apr 06, 2018 5:11 am
Thanks but that looks like it will only run on the GUI I run headless no GUI. Sounds like it would work
You can use the piclone command in the CLI to perform the same task using a card reader and SD card.

Having run both, it looks like SD copy uses piclone.
sure? or you talk about
rpi-clone https://github.com/billw2/rpi-clone

anyhow both tools
++ piclone ( run desktop === SD Card copier )
apt-cache show piclone
++ rpi-clone ( CLI tool )
ls /usr/local/sbin/rpi-clone
create a backup of a running system to a then bootable SD Card / USB stick
and do not create a .img or .img.zip file what could be stored on PC, send by internet filesharing , and later burned by etcher.

RonR
Posts: 411
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: backup

Fri Apr 06, 2018 5:16 pm

bertlea wrote:
Fri Apr 06, 2018 8:48 am
The "image-backup" script RonR provided looks like a great solution comparing to what I am using. I have a few questions:

1. The script need to be run as root? I.e. run it with “sudo”?
2. It will only backup the system (and all files) on the SD card, not other USB drive attached to right?
3. The target drive shall not in FAT32 format as the image file may be better than 4G right? So it must be a drive in ext-4?
4. Can the target drive / folder be a network shared samba folder? i.e. I can backup to my Windows HDD via shared folder right?
5. We can trust that script is safe as the link is form this forums’ download link right? I do not have the knowledge to understand fully this bash script.... :(
Yes to everything, except...

3. The target drive can be any drive (other than the SD card being backed up) with sufficient capacity to hold the backup image file and any format that your Raspbian system can read/write. The backup image file does not have to be as large as the source media. The backup image file need only be large enough to hold the actual contents of the source media (plus some additional room for expansion, if you plan to incrementally update it).

image-backup also works with systems running on a USB storage device instead of an SD card.

bertlea
Posts: 274
Joined: Wed Dec 07, 2016 6:33 am
Location: Hong Kong

Re: backup

Sat Apr 07, 2018 1:53 am

Thanks RonR! Will try that script this month.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: backup

Sat Apr 07, 2018 3:06 am

RonR wrote:
Fri Apr 06, 2018 5:16 pm
bertlea wrote:
Fri Apr 06, 2018 8:48 am
3. The target drive shall not in FAT32 format as the image file may be better than 4G right? So it must be a drive in ext-4?
Yes to everything, except...

3. The target drive can be any drive (other than the SD card being backed up) with sufficient capacity to hold the backup image file and any format that your Raspbian system can read/write. The backup image file does not have to be as large as the source media. The backup image file need only be large enough to hold the actual contents of the source media (plus some additional room for expansion, if you plan to incrementally update it).

image-backup also works with systems running on a USB storage device instead of an SD card.
+ i used a RPI3 B with current RASPBIAN Desktop on a 32GB USB stick
+ i used a 8GB USB stick FAT32 and got a error: "file too large"
gparted format USBstick_8GB from FAT32 to EXT4 ( remove/insert USBstick )
_______________________

Code: Select all

[email protected]:~/projects/image_backup $ sudo bash image-backup

Image file to create? /media/pi/dc9448da-f8f7-4d8c-9147-fdf28f2b03d8/my_raspbian.img

Image ROOT filesystem size (MB) [29616]? 0

Requested image ROOT filesystem size (0) is too small (Minimum = 6603)

Image ROOT filesystem size (MB) [29616]? 6603

Create /media/pi/dc9448da-f8f7-4d8c-9147-fdf28f2b03d8/my_raspbian.img [6603 MB] (y/n)? y

Starting full backup (for incremental backups, run: image-backup /media/pi/dc9448da-f8f7-4d8c-9147-fdf28f2b03d8/my_raspbian.img)
i zipped that back to the System drive

Code: Select all

[email protected]:/media/pi/dc9448da-f8f7-4d8c-9147-fdf28f2b03d8 $ sudo zip /home/pi/projects/image_backup/my_raspbian.img.zip my_raspbian.img
  adding: my_raspbian.img (deflated 66%)
and
gparted format USBstick_8GB from EXT4 to FAT32 ( remove/insert USBstick )

Code: Select all

[email protected]:~/projects/image_backup $ mv my_raspbian.img.zip /media/pi/B4BC-B04C/
but can not open from windows 7 ( it need to format the USB stick )

but anyhow, @bertlea your warning was good!

________________________________
in a second test i used RPI2 with a 14GB Noobs-Raspbian desktop setup
and a cleaned 8GB FAT32 USB stick

Code: Select all

umount /dev/sda1
sudo mkfs.ext4  -F -L "CLEANext4" /dev/sda1
or gparted
( stick remove/insert )

Code: Select all

sudo bash image-backup
Image file to create? /media/pi/CLEANext4/my_raspbian.img
Image ROOT filesystem size (MB) [15022]? 6850
Create /media/pi/CLEANext4/my_raspbian.img [6850 MB] (y/n)? y
Starting full backup (for incremental backups, run: image-backup /media/pi/CLEANext4/my_raspbian.img)

zip /home/pi/Desktop/share/my_raspbian.img.zip my_raspbian.img
  adding: my_raspbian.img (deflated 52%)
# format 8GB USB stick format... ext4 (3min)
# image backup (20min)
# zip (44min)
# move to PC via windows explorer from RPI2 samba share (5min)
# burn same SD via etcher from that zip file (10min + 7min validate )
#boot in RPI2
[!! end kernel panic not syncing VFS unable to mount root fs at block

@RonR
can
image-backup
backup NOOBS/PINN system SD cards?
Last edited by KLL on Sun Apr 08, 2018 1:38 am, edited 1 time in total.

RonR
Posts: 411
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: backup

Sat Apr 07, 2018 10:16 pm

KLL wrote:
Sat Apr 07, 2018 3:06 am
can
image-backup
backup NOOBS/PINN system SD cards?

image-backup assumes you're backing up a normal two-partition Raspbian system (fat + ext4/f2fs).

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: backup

Mon Apr 09, 2018 2:42 am

thanks @RonR,
now i think i got it: ( from my BLOG)
here at try 4th:
SOURCE: system SD 8GB ( my master RASPBIAN desktop ( from image / 2 partitions ) running
TARGET: 8GB USB stick (FAT32)

-a- format USB stick to ext4
-b- image-backup
-c- incremental backup
-d- look inside that backup .img file ( like for restore one file only )
-e- reconfig SAMBA so windows PC can read that .img file
-f- network transfer and zip to PC
-g- burn to 16GB SD card with etcher and boot in RPI and increase file system

Return to “Beginners”