Hetzner - DokuWiki

Sftpclone/en
(first draft)
 
Zeile 1: Zeile 1:
'''SFTPClone backup'''
+
== SFTPClone backup ==
  
 
[https://github.com/unbit/sftpclone sftpclone] is an SFTP based backup software that works similarly to rsync. In fact, it copies and keeps updated the whole tree underneath a specific directory, managing at the same time to update symbolic links, access times, and so on.
 
[https://github.com/unbit/sftpclone sftpclone] is an SFTP based backup software that works similarly to rsync. In fact, it copies and keeps updated the whole tree underneath a specific directory, managing at the same time to update symbolic links, access times, and so on.
Zeile 36: Zeile 36:
  
 
Once you have chosen the sftpclone command/configuration that best suits your needs, you can set a cronjob to let the backup process happen on a regular basis:
 
Once you have chosen the sftpclone command/configuration that best suits your needs, you can set a cronjob to let the backup process happen on a regular basis:
You can thus store a script either under /etc/cron.daily (daily), /etc/cron.weekly (weekly) or /etc/cron.monthly (monthly).  
+
You can thus store a script either under /etc/cron.daily (daily), /etc/cron.weekly (weekly) or /etc/cron.monthly (monthly).
 
A crontab can also be used to schedule an exact time by setting up a file under /etc/cron.d/:
 
A crontab can also be used to schedule an exact time by setting up a file under /etc/cron.d/:
 
<pre>
 
<pre>
Zeile 49: Zeile 49:
 
</pre>
 
</pre>
  
[[Kategorie:backup]]
+
[[Kategorie:Backup]]
[[Kategorie:sftpclone]]
+
[[Kategorie:Sftpclone]]

Version vom 13. April 2015, 09:41 Uhr

SFTPClone backup

sftpclone is an SFTP based backup software that works similarly to rsync. In fact, it copies and keeps updated the whole tree underneath a specific directory, managing at the same time to update symbolic links, access times, and so on.

It's written in Python (supports both version 2 and 3) and you can install it by using PIP:

# you can choose to install it either in user or root space
$ pip install sftpclone --user
$ sudo pip install sftpclone

Once installed you'll get an sftpclone executable. Use the -h flag to inspect all the possible configuration parameters and check the project page for more detail docs.

$ sftpclone -h

usage: sftpclone [-h] [-k private-key-path]
                    [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG,NOTSET}] [-p PORT]
                    [-f] [-a] [-c ssh config path] [-n known_hosts path] [-d]
                    [-e exclude-from-file-path]
                    local-path user[:password]@hostname:remote-path

The simplest possible configuration only specifies the local folder to backup and the remote endpoint:

$ sftpclone local-path user[:password]@hostname:remote-path

As usual, clear text password are bad. So you should specify your private key and use it to avoid password login, as explained here. Note that, if you don't specify a password, sftpclone will automatically fallback to public key authentication.

You can also specify a list of files to be ignored, see here.

Warning: be sure to select a proper remote folder. The synchronization process will indeed delete any file that doesn't exist in the local folder.

Once you have chosen the sftpclone command/configuration that best suits your needs, you can set a cronjob to let the backup process happen on a regular basis: You can thus store a script either under /etc/cron.daily (daily), /etc/cron.weekly (weekly) or /etc/cron.monthly (monthly). A crontab can also be used to schedule an exact time by setting up a file under /etc/cron.d/:

# /etc/cron.d/sftpclone
0 0 * * * root sftpclone local-path user[:password]@hostname:remote-path [-k private-key-path] > /dev/null 2>&1

Here we provide a full working example:

# /etc/cron.d/sftpclone
0 0 * * * root sftpclone / aldur@aldur-host:root_backup > /dev/null 2>&1


© 2020. Hetzner Online GmbH. Alle Rechte vorbehalten.