Make password-less server connections
- On the local machine generate ssh certificates:
ssh-keygen
- And register that machnie on destination/remote machine:
ssh-copy-id username@destination
Backup command:
If you prefer overwriting the contents, the "overwriting" part has to be figured out too; but in a nutshell, need no archive-rotation software, you can use plain tar or scp for moving files, like this semi-oneliner.
(In order to fit that in one line, add ; like this: cd bak-this-dir;. One-liners are needed in crontabs.)
cd backup-this-directory
tar czvf - | ssh username@destination "cd backup-destination; dd | tar xzf -"
Or the other way round - if you want to upload files to your local machine:
cd backup-destination
ssh username@destination "cd backup-this-directory; tar czf -" | dd | tar xzvf -
Variants:
- you could leave the file compressed, in which case
dd could be your reveiving end with dd of=`date '+%F'`-backup.tgz
- no need for
z tar option if source is hard to compress (like videos) or bandwith is not a limitation.
Comments:
% characters have to be escaped in chron tab,
dd adds you the speed-meter to your transmission,
- remember to
cd into your appropriate directories, or tar will make a "tar-bomb" by possibly littering a homedir with many small files from backup source.