Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 35 lines (26 sloc) 1.04 KB
#!/bin/bash
source $HOME/.manta_config
source $HOME/.mbackup_config
if [ -z "$2" ]; then
echo "Usage: $0 <data_type> <file> <target_path (optional)>"
echo " eg $0 postgres my_table.date.gz /$MANTA_USER/stor/postgres/your_dir"
exit
fi
if [ -z "$3" ]; then
targetdir="/$MANTA_USER/stor/backups/$1/$(hostname)"
else
targetdir="$3"
fi
file=$(echo -n $2 | awk 'BEGIN{FS="/"}{ print ( $(NF-0) ) }')
log_date=$(date '+%d/%b/%Y:%H:%M:%S %z')
mmkdir -p $targetdir
if [ "$(md5sum $2 | cut -d ' ' -f 1)" == "$(mmd5 $targetdir/$file 2>/dev/null | cut -d ' ' -f 1)" ]; then
echo "[$log_date] $targetdir/$file already exists and has the same checksum as $2. Skipping..."
exit 0
fi
echo "[$log_date] Backing up $2 to $targetdir/$file..."
mput -f $2 -H content-md5:$(cat $2 | openssl md5 -binary | openssl enc -base64) $targetdir/$file
# Report errors during the mput stage. Configure the 'errors_email' variable in .mbackup_config
if [ "$?" != "0" ]; then
echo "mbackup encountered errors while transferring $file to $targetdir." | mailx $ERRORS_EMAIL
fi
You can’t perform that action at this time.