Solved

Linux Commands for Remote Backup

Posted on 2016-10-10
5
52 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: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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
digital ocean web console access ? does it use port 22 4 53
RHEL 6.7 Gnome Desktop on VMware 6 VM 9 109
list of sudo access for date range 5 34
plsql job on oracle 18 73
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

740 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