Solved

Linux Commands for Remote Backup

Posted on 2016-10-10
5
42 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 40

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check if a filw is immutable for a certain amount of time 6 61
AWS - HAProxy- KeepAlived 5 43
mcrypt_create_iv() is deprecated 4 160
expectj telnet failing 5 36
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

777 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