Automated remote backup with rclone

Discussion in 'Tips/Tricks/Mods' started by HenrysCat, Mar 30, 2020.

  1. HenrysCat

    HenrysCat Member

    After much searching I was unable to find a satisfactory solution to backup the /var/backup/ folder (which is where ISPConfig stores the backup files) to a remote server, so I came up with this to backup from VPS to my Synolgy nas drive located at home and thought I would share.

    First you need to install rclone (I use debian 10)
    So login to a command line and enter
    curl | sudo bash
    Once installed type 'rclone config'

    Type n, then give it a name in this example we are using the name sftpbackup

    (all steps below are seperated by commas)

    Select 29 for SSH/SFTP Connection (this seems to change with version updates but correct as of v1.51.0)
    add your host name/ip address for the SFTP server, user name, port number, Type 'y' for own password, enter password, press enter for default, type 'g' generate random pasword, 1024, yes (dont forget to save the password), press enter for default, press enter for default, press enter for default, 'n' to edit advanced config, type 'y' this is ok, type q to quit

    Next create a shell script, type
    nano /usr/local/ispconfig/server/
    copy/paste the below (this is for my Synology nas at home, you need to edit the /volume1/Backup/Backup part to suit your nas)
        if pidof -o %PPID -x ""; then
        exit 1
        rclone copy /var/backup/ sftpbackup:/Backup/Backup --sftp-path-override /volume1/Backup/Backup
    Type ctrl X, then y, then enter to save

    now make the file executable
    chmod a+x /usr/local/ispconfig/server/
    Now add a cron to run the script,
    crontab -e
    add to the bottom
    0 5 * * * /usr/local/ispconfig/server/ >/dev/null 2>&1
    This will run every day at 5am

    To test the script run
    This is not limited to nas drives, rclone supports many different backup solutions, just use the above and adapt as necessary.
    Hope this helps someone, any questions just ask.
    Last edited: Mar 31, 2020
    till likes this.

Share This Page