Advertisement: Linux VPS from $4/month - contact support for custom offer.
+ Post New Thread
Results 1 to 2 of 2

Thread: Script to regularly download backups from remote server

  1. #1
    Join Date
    Mar 2013

    Script to regularly download backups from remote server

    # Script to download backups to local server
    # - delete old backups
    # - kills all locally runnign rsync before running rsync
    # - send an email notiffying that this script finished running

    # sleep some time so todays backup is started to be made
    sleep 5

    # variables
    $yesterday="date -d \"1 day ago\" \"+%Y-%m-%d\""
    $today="date \"+%Y-%m-%d\""
    ip_cp="" # remote server IP (source of backups)

    speed="5000" # max. transfer speed in kb
    maill="[email protected]"

    # optional SSH access key setup
    if [ "$sshkeysetup" == "yes" ];then
    echo "-----------------------
    Can we run ssh-keygen & ssh-copy-id now? Key will be sent to $ip_cp server so this remote server knows he should allow incoming connections of this local server.
    y (yes, start) or any key (no, exit)"
    read kgcp
    if [ "$kgcp" == "y" ];then
    ssh-copy-id -i ~/.ssh/ "$ip_cp -p $sshport"
    sleep 3
    echo "Listing remote authorized_keys file now..." && sleep 3
    ssh -p $sshport $ip_cp 'cat ~/.ssh/authorized_keys;exit'
    echo "SSH key setup finished, hope that successfully.. Now Bakcup script continuing..." && sleep 9

    # list remote server bakcp dir contents (maybe for purpose to check if some bakcup is there)
    # rmtservbckpdircontents="$(ssh -p $sshport $ip_cp 'ls -A1 $ip_cp_pathdest;exit')"
    # if [[ "$rmtservbckpdircontents" == *"$today"* ]];then

    # delete local backup files not modiffied more than 720 hours (30 days)
    tmpwatch -m 720 $ip_cp_pathdest

    # make sure no rsync is already running (kill all locally running rsync)
    pkill -f "rsync"

    # rsync backups from remote server
    /bin/nice -n 19 /usr/bin/ionice -c2 -n7 rsync -au --size-only --progress --bwlimit=$speed -e "ssh -p $sshport" [email protected]$ip_cp:$ip_cp_path $ip_cp_pathdest

    echo "Backups downloader script located on $(hostname) finished. This script is probably located in /etc/cron... or /root" | mail -s "Backups downloader - $(hostname)" $maill
    If you need script that not download backups from remote server, but upload local server bakcups to remote server, please check this topic for slightly better written script.

    Script mentioned in this topic generating ssh access key and upload it to remote server (from which backups wlll be downloaded). After first run, edit script and change "sshkeysetup="yes"" to no so only backups are made on next runs.

  2. #2

    Is this useful / helpfull? Yes | No
    ILF is a web that is enhanced by the google for working capacity and digital monitoring of them in the status formation. The thread post has the visuals of customwritings com in the downloading of the backups with remote server to save the alliance in good manners.

+ Post New Thread

Similar Threads

  1. Replies: 0
    Last Post: 03-15-2017, 10:24 PM
  2. Replies: 0
    Last Post: 07-11-2016, 06:16 AM
  3. Replies: 0
    Last Post: 10-25-2015, 09:09 AM
  4. Replies: 0
    Last Post: 11-16-2014, 07:18 PM
  5. Replies: 0
    Last Post: 11-02-2014, 06:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
 Protected by : ZB BLOCK  &  StopForumSpam