Smart Home Automation with Linux and Raspberry Pi by Steven Goodwin
Author:Steven Goodwin
Format: epub, pdf
Publisher: Apress
To make a direct copy of one set of files from one directory to another, you can probably use cp at the end of each day. However, this will wastefully copy files that haven’t changed, and so rsync was born. rsync is a very old copy and backup program but is still a venerable workhorse. I make backups of my code directory, for example, with this single line:
rsync -a code [email protected]:∼/backup/daily
I recover them (for testing8) with this:
rsync -a [email protected]:∼/backup/daily code
The options here perform a recursive update, while maintaining all symlinks, permissions, and user settings and is the most typical in home situations. The manual pages detail other possibilities.
rsync does have two problems, however. The first is that it’s available primarily for Unix-oriented platforms. Versions are available for Windows (such as DeltaCopy and the version with Cygwin), but they take a little while to set up and can be tricky.
The second issue is that it requires a password to be interactively given in order to log in to the remote site. This is a nuisance and prevents any kind of automatic backup. For a remote site to allow a user to connect without a password, they must first establish an alternative form of trust—in this case, the exchange of public keys. To copy from machine A to machine B, B must have a copy of A’s public key. To copy from machine B to machine A, A must have a copy of B’s public key. In our case, machine A is at home with our files, while B is a remote machine for backup.
So, our home machine must generate a key for the user who’ll be doing the copying.
ssh-keygen -t rsa
which by default can be found in ∼/.ssh/id_rsa.pub. This is then copied to the remote machine (perhaps using a password-directed rsync) and appended to the list of authorized keys that the remote user will accept:
cat id_rsa.pub >> ∼/.ssh/authorized_keys
Once this is done, you should be able to rsync without a password:
rsync -a --bwlimit=100 [email protected]:∼/backup/daily code
Note that this limits the bandwidth (with the bwlimit argument) to 100 kilobytes per second so that other applications can make use of the Internet, since rsync and ssh are rather greedy when teamed up together.
One potential administration problem that can exist here is for the home user to be refused a connection because the address from which they’re connecting does not match the one used in the key. This can happen when the hostname is something simply like linuxbox1 but appears to the remote machine as netpc-london-isproute-isp.com or something equally unhelpful. The target machine, by comparison, will usually have a fixed name because it must be addressable from the outside world. Because the home machine name might change (at the whim of the ISP), the easiest solution is to reverse all the instructions given here! That is, use the remote server to connect to the home server, generate a key for the remote server only, and reverse the arguments to the rsync command so that the remote server pulls the data from the home machine in order to perform the backup.
Download
Smart Home Automation with Linux and Raspberry Pi by Steven Goodwin.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Whiskies Galore by Ian Buxton(40537)
Introduction to Aircraft Design (Cambridge Aerospace Series) by John P. Fielding(32350)
Small Unmanned Fixed-wing Aircraft Design by Andrew J. Keane Andras Sobester James P. Scanlan & András Sóbester & James P. Scanlan(32149)
Craft Beer for the Homebrewer by Michael Agnew(17464)
Turbulence by E. J. Noyes(7061)
The Complete Stick Figure Physics Tutorials by Allen Sarah(6650)
Kaplan MCAT General Chemistry Review by Kaplan(6071)
The Thirst by Nesbo Jo(5800)
Bad Blood by John Carreyrou(5784)
Learning SQL by Alan Beaulieu(5428)
Weapons of Math Destruction by Cathy O'Neil(5053)
Man-made Catastrophes and Risk Information Concealment by Dmitry Chernov & Didier Sornette(4751)
iGen by Jean M. Twenge(4708)
Digital Minimalism by Cal Newport;(4576)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(4524)
Audition by Ryu Murakami(4109)
Electronic Devices & Circuits by Jacob Millman & Christos C. Halkias(4052)
1,001 ASVAB Practice Questions For Dummies by Powers Rod(4050)
Pale Blue Dot by Carl Sagan(4019)