ein Blog

Backup to OVH Cloud Archive

OVH provides "Cloud Archive" Storage: https://www.ovh.com/us/public-cloud/storage/cloud-archive/

You can write to it via standard protocols and i decided to create a backup script for that. It uses lftp and a basic incremental strategy.

To obtain the proper credentials, follow this guide. (just download the OpenStack config from the OVH webinterface. Username and tenant name doesn't seem to be available anywhere else)

#!/bin/bash

set -e

##### CHANGE OPTIONS HERE #####
ovh_tenant="8313562441481978"
ovh_username="go5Ahsu0Sees"
ovh_password="Bae2Ahh2xeen8oa8eiphaiwie8Azi8Ae"
ovh_endpoint="gateways.storage.sbg3.cloud.ovh.net"
##### END #####

date=$(date +%Y-%m-%d_%H-%M-%S)
date +%c | tee /var/log/ovhbackup.$$

if [[ ! -f /var/log/ovhbackup.ts ]]; then
    # initial backup should take everything
    touch -d 1970-01-01 /var/log/ovhbackup.ts
    date="init"
fi

lftp -u pca,${ovh_tenant}.${ovh_username}.${ovh_password} sftp://${ovh_endpoint} << EOF
mkdir -p hostname/stuff/${date}/
mirror -vvv --no-empty-dirs --no-symlinks --no-perms --no-umask --newer-than=/var/log/ovhbackup.ts -R /storage/stuff hostname/stuff/${date}
# add more mirror lines here as required
EOF

mv /var/log/ovhbackup.$$ /var/log/ovhbackup.ts

! Note: this does no validation and relies on working mtime !