Solved

Linux Commands for Remote Backup

Posted on 2016-10-10
5
32 Views
Last Modified: 2016-11-01
Hi

I'm looking to backup Raspberry Pi remotely to a NAS server. I am looking to use the following sequential commands :

sudo /etc/init.d/lighttpd stop
sudo /etc/init.d/noip stop
sudo /etc/init.d/cron stop
sudo dd if=/dev/mmcblk0 of=/testnas01/backups/raspberryPiSDCardBackup.img
sudo /etc/init.d/cron start
sudo /etc/init.d/lighttpd start
sudo /etc/init.d/noip start
0
Comment
Question by:L-Plate
5 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 41837810
are you trying to backup to local storage or you want to backup to remote system?
0
 
LVL 47

Assisted Solution

by:dlethe
dlethe earned 250 total points (awarded by participants)
ID: 41837814
Do you have an actual question?    But i expect you want to take an image back up a Pi that is booted, and running networking services, AND has a read/write filesystem.

No. You can't do that.  (Well, you can, but the backup, then of course, the restore will be corrupted because you are changing files while backing up).

There are some Pi O/S variations that are pure read-only (/tmp is a ramfs).   Now if you had a read-only FS then you could wouldn't need to stop any services, and it would work because data files aren't changing ..  but then again if you had a read-only filesystem, then you wouldn't need to make frequent backups of it, since it doesn't change.
0
 
LVL 39

Accepted Solution

by:
noci earned 250 total points (awarded by participants)
ID: 41837968
Yes it will dump the mmc card to a remote location....
BEFORE doing dd... do

sync; sync; sync
sleep 5

Then at least all data is dumped to the card first. sleep a while to await dumping of data.
Best would be to do syn; sync; sync and remount all Filesystems as read only, but that will require stopping all services...
{ stop services }
sleep 5       # wait for lagging services
sync; sync; sync     # dump all memory buffers
sleep 5     # wait for last writes
mount -o remount,ro .....
{ dd }
mount -o remount,rw ....
{ start services }

Effectively the not saving of this data is what corrupted most MMC cards with the early raspbian systems that never did a sync, and turning off the device would destroy at least some of the data/structure on a disk.
(It still might).

A better option is create one writeable part of the filesystem that is mounted rw while the whole filesystem is mounted ro, and dismount that
part short before dd and remount after dd  much safer.
1
 
LVL 47

Expert Comment

by:dlethe
ID: 41865731
auto close initiated
0
 

Author Comment

by:L-Plate
ID: 41868217
Thanks for your time on this very sorry I did not get back to close off and allocate the points.

I ended up backing/restoring up the Linux box locally to a USB stick using Win32 from Sourceforge
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now