Skip to content
Snippets Groups Projects
Select Git revision
  • 134ad2d56ecc5013689489b24265f555288870bc
  • main default protected
2 results

WikiAbstract-SolarSystem-11.stog.amr.ttl

Blame
  • restore_file.sh 1.10 KiB
    #!/bin/bash
    DIR=$(realpath $(dirname $0))
    usage(){
        echo "Usage $0 [options] <restore_path> <destination_path>"
        echo "restore_path      :   path to restore without leading slash"
        echo "destination_path  :   path to download the file(s), duplicity will not override existing files"
        echo "options"
        echo "    -t timeago    :   the age of the version we want to restore, for instance 6D for 6 days ago"
        echo "    -c file       :   config_file to use"
    }
    
    while getopts "t:c:h" arg; do
        case ${arg} in
            h)
                usage
                exit 0
                ;;
            t)
                delay="-t $OPTARG"
                ;;
            c)
                conf_file=$OPTARG
                ;;
        esac
    done
    restore_path=${@:$OPTIND:1}
    destination_path=${@:$OPTIND+1:1}
    
    if [ -z "$destination_path" ]; then
        usage
        exit 1
    fi
    
    source $DIR/inc.sh
    
    export PASSPHRASE="$encpass"
    export FTP_PASSWORD="$ftppass"
    
    set -x
    /usr/bin/duplicity   --verbosity $verbosity \
        --timeout $timeout \
        $delay \
        --file-to-restore "$restore_path" \
        $remote "$destination_path"
    set +x
    
    unset PASSPHRASE
    unset FTP_PASSWORD