Fidonet Portal






From: john ford (3:770/100)
To: n/a
Date: Sat, 22.02.20 13:41
Backup script
Backup script i made in bash, uses bash to config the bash script, dirty
subarray trick

script:
#!/usr/local/bin/bash
#settings
DATE=$(date "+%m_%d_%y_%H:%M"Wink
source ~/.backuprc
set -euf -o pipefail

help="$0 {zfs|rsync} {job}"

backup_rsync( Wink
{
tobed=$(eval echo \${"${rsync[$2]}"["source"]})
dest=$(eval echo \${"${rsync[$2]}"["destination"]})
location=$(eval echo \${"${rsync[$2]}"["location"]})
excludes=$(eval echo \${"${rsync[$2]}"["exclude_file"]})
basicflags=$(eval echo \${"${rsync[$2]}"["flags"]})
if [ "$location" == "local" ]
then
destination=${locations["$2"]}
flags="$basicflags"
else
if [ "$location" == "ssh" ]
then
sshinfo=$(eval echo \${"${rsync[$2]}"["ssh"]})
server=$(eval echo \${"$sshinfo"["user_server"]})
identfile=$(eval echo \${"$sshinfo"["identity"]})
sshport=$(eval echo \${"$sshinfo"["port"]})
dest="$server:$dest"
flags="$basicflags -e 'ssh -i $identfile -p $sshport'"
fi
fi
if [[ $excludes != 0 ]]
then
flags="$flags --exclude-from=$excludes"
fi
if [[ $(eval echo \${"${rsync[$2]}"["delete"]}) != 0 ]]
then
flags="$flags --delete"
fi
eval "rsync $flags $tobed $dest"
}

backup_zfs( Wink
{
tobed=$(eval echo \${"${zfs[$2]}"["source"]})
destination=$(eval echo \${"${zfs[$2]}"["destination"]})
location=$(eval echo \${"${zfs[$2]}"["location"]})
recflags=$(eval echo \${"${zfs[$2]}"["recvflags"]})
destroyflags=$(eval echo \${"${zfs[$2]}"["destroyflags"]})
sendflags=$(eval echo \${"${zfs[$2]}"["sendflags"]})
snapflags=$(eval echo \${"${zfs[$2]}"["snapflags"]})
incremental=$(eval echo \${"${zfs[$2]}"["incremental"]})
echo $incremental
checkdest="zfs list $destination"
if [ "$location" == "local" ]
then
receiver="zfs receive $recflags"
destroyer="zfs destroy $destroyflags"
else
if [ "$location" == "ssh" ]
then
sshinfo=$(eval echo \${"${zfs[$2]}"["ssh"]})
identfile=$(eval echo \${"$sshinfo"["identity"]})
userserver=$(eval echo \${"$sshinfo"["user_server"]})
sshport=$(eval echo \${"$sshinfo"["port"]})
sshline="ssh -t $userserver -i $identfile -p $sshport"
receiver="$sshline zfs receive $recflags"
destroyer="$sshline zfs destroy $destroyflags"
checkdest="$sshline $checkdest"
fi
fi
eval "zfs snapshot $snapflags $tobed@$DATE"

if [ "$incremental" == "yes" ]
then
if eval "$checkdest" && eval "ls ~/.$2.zfs.lastsnap"
then
lastsnap=$(cat ~/."$2".zfs.lastsnap)
sendflags="$sendflags -i $tobed$lastsnap"
#echo $sendflags
fi
echo "@$DATE" > ~/."$2".zfs.lastsnap
else
eval "$destroyer $destination"
fi
sleep 5
eval "zfs send $sendflags $tobed@$DATE | $receiver $destination"
}

if [ $# == 0 ]
then
echo "$help"
exit
else
case $1 in
rsync)
backup_rsync "$@"
exit
;;
zfs)
backup_zfs "$@"
exit
;;
*)
echo "$help"
exit
;;
esac
fi

The "config"
DELETE=1
HOMEDIR=/usr/home/mouse/
HOMEZFS="mouser/usr/home/mouse"
HOMEEXCLUDE="/usr/home/mouse/.rsync_excludes"
GLOBALEXCLUDE="/usr/home/mouse/.rsync_global_excludes"
DEFAULTSERVER="192.168.1.138"
DEFAULTUSER="mouse"

declare -A home_ssh=(
["user_server"]="$DEFAULTUSER@$DEFAULTSERVER"
["port"]="1478"
["identity"]="~/.ssh/id_rsa_home"
Wink

declare -A ssh=(
["home"]=home_ssh
Wink

declare -A full_rsync=(
["delete"]=0
["source"]="/"
["flags"]="-avP"
["destination"]="/suplbup/laptop/"
["exclude_file"]=$GLOBALEXCLUDE
["location"]="local"
Wink

declare -A fullssh_rsync=(
["delete"]=1
["source"]="/"
["flags"]="-avP"
["destination"]="/massdata/laptop/"
["exclude_file"]=$GLOBALEXCLUDE
["location"]="ssh"
["ssh"]=home_ssh
Wink

declare -A home_rsync=(
["delete"]=1
["source"]=$HOMEDIR
["flags"]="-avP"
["destination"]="/suplbup/laptop-home/"
["exclude_file"]=$HOMEEXCLUDE
["location"]="local"
Wink

declare -A music_rsync=(
["delete"]=0
["source"]="/usr/home/mouse/music/"
["flags"]="-avP"
["destination"]="/home/mouse/Music/"
["exclude_file"]=$HOMEEXCLUDE
["location"]="ssh"
["ssh"]=home_ssh
Wink
declare -A freenet_rsync=(
["delete"]=0
["source"]="/usr/home/mouse/Freenet/"
["flags"]="-avP"
["destination"]="/home/mouse/Freenet/"
["exclude_file"]=$HOMEEXCLUDE
["location"]="ssh"
["ssh"]=home_ssh
Wink

declare -A homessh_rsync=(
["delete"]=1
["source"]=$HOMEDIR
["flags"]="-avP"
["destination"]="/massdata/laptop-home/"
["exclude_file"]=$HOMEEXCLUDE
["location"]="ssh"
["ssh"]=home_ssh
Wink

declare -A homessh_zfs=(
["source"]=$HOMEZFS
["recvflags"]=""
["snapflags"]="-r"
["destroyflags"]="-r"
["sendflags"]="-v -R"
["destination"]="imagine/test"
["location"]="ssh"
["incremental"]="yes"
["ssh"]=home_ssh
Wink

declare -A home_zfs=(
["source"]=$HOMEZFS
["recvflags"]=""
["snapflags"]="-r"
["destroyflags"]="-r"
["sendflags"]="-v -R"
["destination"]="suplbup/rescuehome"
["location"]="local"
["incremental"]="yes"
Wink

declare -A full_zfs=(
["source"]=mouser
["recvflags"]=""
["snapflags"]="-r"
["destroyflags"]="-r"
["sendflags"]="-v -R"
["destination"]="suplbup/rescue"
["location"]="local"
["incremental"]="yes"
Wink
declare -A fullssh_zfs=(
["source"]=$HOMEZFS
["recvflags"]=""
["snapflags"]="-r"
["destroyflags"]="-r"
["sendflags"]="-v -R"
["destination"]="imagine/test"
["location"]="ssh"
["incremental"]="yes"
["ssh"]=home_ssh
Wink

declare -A zfs=(
["full"]=full_zfs
["full_ssh"]=fullssh_zfs
["home"]=home_zfs
["home_ssh"]=homessh_zfs
Wink

declare -A rsync=(
["music"]=music_rsync
["freenet"]=freenet_rsync
["full"]=full_rsync
["full_ssh"]=fullssh_rsync
["home"]=home_rsync
["home_ssh"]=homessh_rsync
Wink

--- Mystic BBS v1.12 A45 2020/02/18 (Windows/32)
* Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (3:770/100)

ABOUT

This forum contains echomail areas hosted on Nightmare BBS You can browse local echomail areas, italian fidonet areas and a selection of international fidonet areas, reading messages posted by users in Nightmare BBS or even other BBSs all over the world. You can find file areas too (functional to fidonet technology). You can browse echomail areas and download files with no registration, but if you want to write messages in echomail areas, or use fidonet netmail (private messages with fidomet technology), you have to register. Only a minimal set of data is required, functional to echomail and netmail usage (name, password, email); a registration and login with facebook is provided too, to allow easy registration. If you won't follow rules (each echomail areas has its own, regularly posted in the echomail), your account may be suspended;

CONTACT