?
Solved

Linux Commands for Remote Backup

Posted on 2016-10-10
5
Medium Priority
?
66 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:David
David earned 1000 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 1000 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:David
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

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

Question has a verified solution.

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

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.:
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.
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 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