There is already a thread about an automated backup using a cronjob on the Freetz-box.
But I would like to get some pointers on how to write an automated script on a linux server that's pulling all the configs..
I wrote such a script in the past and it was even able to do a mixed set of routers (netscreen, cisco, siemens and speedtouch)....
Every brand had its specialized method of obtaining a config.
I would like to write such a script again, but then for freetz
I can do the whole thing, but I do need to know what to do to get the actual config (using curl or wget)
This is how I do it for my pfsense router...
I would really like to know how to do something similar on a Freetz router.
Maybe even using the AVM-interface (or both)....
The whole cronjob looks like this (most code is about getting rid of the config files that are (almost) the same as the previous one):
But I would like to get some pointers on how to write an automated script on a linux server that's pulling all the configs..
I wrote such a script in the past and it was even able to do a mixed set of routers (netscreen, cisco, siemens and speedtouch)....
Every brand had its specialized method of obtaining a config.
I would like to write such a script again, but then for freetz
I can do the whole thing, but I do need to know what to do to get the actual config (using curl or wget)
This is how I do it for my pfsense router...
Code:
wget -qO/dev/null --keep-session-cookies --save-cookies /tmp/pfsense_cookies.txt --post-data "login=Login&usernamefld=${USER}&passwordfld=${PASS}" ${WGETOPT} ${PROTO}://${IP}:${PORT}/diag_backup.php
wget -qO${FNAME} --keep-session-cookies --load-cookies /tmp/pfsense_cookies.txt --post-data 'Submit=download&donotbackuprrd=yes' ${WGETOPT} ${PROTO}://${IP}:${PORT}/diag_backup.php
I would really like to know how to do something similar on a Freetz router.
Maybe even using the AVM-interface (or both)....
The whole cronjob looks like this (most code is about getting rid of the config files that are (almost) the same as the previous one):
Code:
#!/bin/sh
DATESTAMP=`date +%Y-%m-%d.%H:%M`
FNAME=pfsense.${DATESTAMP}.xml
FOLDER=/var/www/vhosts/domain.com/pfsense
USER=admin
PASS=secret
PROTO=https # http or https
IP=8.8.8.8 # DNS or IP of webif (remote side)
PORT=9180 # port of webif (remote side)
WGETOPT=
# turn off certificate checking
[ "${PROTO}" = "https" ] && WGETOPT="${WGETOPT} --no-check-certificate"
if cd ${FOLDER} ; then
FGROUP=`stat -c%G .`
FUSER=`stat -c%U .`
LASTXML=`ls -1t pfsense*xml 2>/dev/null | head -n1`
wget -qO/dev/null --keep-session-cookies --save-cookies /tmp/pfsense_cookies.txt --post-data "login=Login&usernamefld=${USER}&passwordfld=${PASS}" ${WGETOPT} ${PROTO}://${IP}:${PORT}/diag_backup.php
wget -qO${FNAME} --keep-session-cookies --load-cookies /tmp/pfsense_cookies.txt --post-data 'Submit=download&donotbackuprrd=yes' ${WGETOPT} ${PROTO}://${IP}:${PORT}/diag_backup.php
if [ -s ${FNAME} ] ; then
chown ${FUSER}:${FGROUP} ${FNAME}
if [ ! -z "${LASTXML}" ] ; then
if [ ! "${LASTXML}" = "${FNAME}" ] ; then
echo '<time>[0-9]+</time>' >/tmp/pfgrep.tmp
echo 'made unknown change' >>/tmp/pfgrep.tmp
echo 'Expired .* user accounts' >>/tmp/pfgrep.tmp
egrep -vf /tmp/pfgrep.tmp ${LASTXML} >${LASTXML}.notime
egrep -vf /tmp/pfgrep.tmp ${FNAME} >${FNAME}.notime
if diff ${LASTXML}.notime ${FNAME}.notime >${FNAME}.diff ; then
rm -f ${FNAME}*
else
chown ${FUSER}:${FGROUP} ${FNAME}.diff
fi
rm /tmp/pfgrep.tmp
rm -f ${LASTXML}.notime 2>/dev/null
rm -f ${FNAME}.notime 2>/dev/null
fi
fi
else
rm -f ${FNAME}
exit 1
fi
else
exit 1
fi
Zuletzt bearbeitet: