lvalnegri

contabo_backup.md

Dec 30th, 2019 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. install tools:

    sudo apt-get install pigz lftp curlftpfs
  2. configure ftp client:

    lftp
    (lftp :~>) set ftp:ssl-force true
    (lftp :~>) set ssl:verify-certificate no
    (lftp :~>) connect <address>
    (lftp <address>:~>) login <usrname>
    (enter password)
  3. create a file called .netrc in the home directory to store credentials with the following content:

    machine <address>
    login <usrname>
    password <pwd>

    Set the permissions on the file so that you are the only user who can read it:

    chmod 0600 ~/.netrc 
  4. create mounting point for ftp server:

    sudo mkdir /mnt/ftp
    sudo curlftpfs -o allow_other,ssl,no_verify_peer <address> /mnt/ftp
  5. create compressed archives using pigz of desired directories/files in some tmp folder:

    hme="/home/usrname"
    tmp=$hme/temp/backup
    fconf="list all configuration files"
    cd $tmp
    tar --exclude=".git*" --exclude="*.Rproj*" --exclude=".Rhistory" --exclude=$tmp -c --use-compress-program=pigz -f $tmp/backup_home.tar.gz $hme/*
    tar -c --use-compress-program=pigz -f $tmp/backup_public.tar.gz $PUB_PATH/*
    tar -czf $tmp/backup_conf.tar.gz $fconf
  6. Move files to ftp folder:

    mv $tmp/* /mnt/ftp
  7. create sh file using 5 and 6 above, then changing permissions:

    chmod +x /home/usrname/cronjob/backup.sh
  8. add entry to crontab (in this way, the script runs at 4AM every Sunday):

    0 4 * * 7  /home/usrname/cronjob/backup.sh
Add Comment
Please, Sign In to add comment