Commit 944b71dd authored by lav's avatar lav

add eterbackup functions

parent 8783216e
#!/bin/sh
fatal()
{
echo "$*" >&2
exit 1
}
mount_remote()
{
[ -n "$BACKUPDIR" ] || BACKUPDIR=/mnt/hetzner-storage
mkdir -p $BACKUPDIR || fatal
[ -n "$BASETARGET" ] || BASETARGET="$(hostname -s)"
mkdir -p $BACKUPDIR/$BASETARGET/ || fatal
# skip if already mounted
[ -r $BACKUPDIR/MARKFILE ] && return
epm assure eterpack eterbackup || fatal
epm assure /sbin/mount.cifs cifs-utils || fatal
[ -n "$CREDFILE" ] || CREDFILE=/root/.cifs
. $CREDFILE
unset password
mount -t cifs //$username.your-storagebox.de/backup $BACKUPDIR -ocredentials=$CREDFILE || fatal
}
# args: abs_dir_from [target_name] [depth] [args]
classic_eterbackup()
{
local FROM="$1"
[ -d "$FROM" ] || fatal "Missed source dir $FROM"
local PARTNAME="$2"
[ -n "$PARTNAME" ] || PARTNAME="$(basename "$FROM")"
local DEPTH="$3"
[ -n "$DEPTH" ] || DEPTH=1
shift 3
nice eterpack update --depth $DEPTH "$@" $FROM $BACKUPDIR/$BASETARGET/$PARTNAME
}
umount_remote()
{
[ -n "$SKIPUMOUNT" ] || umount $BACKUPDIR || fatal
}
SKIPUMOUNT=''
[ "$1" = "--skip-umount" ] && SKIPUMOUNT="$1" && shift
if [ "$1" = "--mount-only" ] ; then
mount_remote
exit
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment