› Forums › Network Management › ZeroShell › [SOLVED] Cron Backup
- This topic is empty.
-
AuthorPosts
-
April 29, 2011 at 2:45 pm #42970
Ihyae
MemberSalve a tutti,
sono nuovo al forum ma uso zeroshell da un po’.. ultimamente si è presentata la necessità di schedulare un dump della cfg su un server remoto..Ho dato un’occhiata agli script presenti nel path: /root/kerbynet.cgi/scripts/
e ho visto tramite console che invocando il backup dalla pagina web, viene lanciato il seguente comando:
/bin/sh /root/kerbynet.cgi/scripts/backupdb /udev/hda3 _DB.001 Yes
ho provato a modificare la riga 60 dello script: /root/kerbynet.cgi/scripts/backupdb in questo modo:
tar cfzv - --exclude var/register/system/havp/tmp/* $EXCLUDE . | uuencode /dev/stdout | ssh root@192.168.0.10 "dd of=/Backup/ITWall-Test.bak" || ERROR
invocando il backup, il file viene generato correttamente ma quando tento di fare il restore (dall’apposito menu) su un’altro zeroshell, propone il seguente errore: “Error during profile restoring!!! “
Da cosa può dipendere ? in che modo posso ovviare il problema ? Nel caso non sia il “metodo” giusto, esiste una via alternativa per schedulare dei backup periodici di zeroshell senza doverli eseguire a mano ?
Saluti,
Dennis—
Hello everyone,
I looked at the script in the path: / root / kerbynet.cgi / scripts /
and I saw through the console and calling up the web page was launched the following command:
/bin/sh /root/kerbynet.cgi/scripts/backupdb /udev/hda3 _DB.001 Yes
I tried to change the line 60 of script: /root/kerbynet.cgi/scripts/backupdb this:
tar cfzv - - exclude var / register / system / havp / tmp / $ * EXCLUDE. | uuencode / dev / stdout | ssh root@192.168.0.10 "dd of =/Backup/ITWall-Test.bak" || ERROR
invoking the backup, the file is generated correctly, but when I try to do the restore (from the menu) to another zeroshell, proposes the following error: “Error During restoring profile!”
May depend on what? how can I solve this problem? If it is not “correct”, there is an alternative way to schedule backups without having to perform it by hand ?
Regards,
DennisMay 2, 2011 at 1:11 pm #51723Ihyae
MemberCosì funziona, il backup viene fatto su un mount point.. il device è USB ma funziona anche in ssh senza problemi, basta cambiare la stringa!
#!/bin/sh
BN=FWN-ITWall-CCC-`date +%a`.bak
source /etc/kerbynet.conf
function UMOUNT () {
cd /
umount $MP/$DB.AUX 2> /dev/null
if [ "$ALREADYMOUNTED" == No ] ; then
umount "$MP" && rmdir "$MP"
fi
}
function ERROR () {
cd /
echo ERROR > "$MP/$DB/.settings/LastBackup"
UMOUNT
exit 1
}
DEV="$1"
DB="$2"
COMPRESSED="$3"
WOLOGS="$4"
[ -z "$DEV" -o -z "$DB" ] && exit 1
$SCRIPTS/umountstorage >/dev/null
NODEV=${DEV:2}
LINE=`df -T -P | grep "$NODEV "`
if [ -z "$LINE" ] ; then
MP=/storage/`echo $DEV | sed -e "s///_/g"`;
mkdir -p "$MP"
mount -o rw "$DEV" "$MP" || exit 1
if [ -r /$MP/$DB.AUX ] ; then
if ! mount -oloop $MP/$DB.AUX /$MP/$DB ; then
UMOUNT
exit 2
fi
fi
ALREADYMOUNTED=No
else
MP=`echo $LINE | cut -f7 -d' '`
mount -oremount,rw "$MP" || exit 1
ALREADYMOUNTED=Yes
if [ -r /$MP/$DB.AUX ] ; then
if ! mount -oloop $MP/$DB.AUX /$MP/$DB ; then
UMOUNT
exit 2
fi
fi
fi
cd "$MP/$DB"
if ! [ -d .settings ]; then
UMOUNT
exit 3
fi
if [ "$WOLOGS" = Yes ] ; then
EXCLUDE='--exclude LOG'
else
EXCLUDE=''
fi
if [ "$COMPRESSED" == Yes ] ; then
rm -rf /mnt/backup/$BN
for N in `seq 1 100` ; do
echo "$N BACKUP $DEV $DB `date` ================================================================================================" >> /mnt/backup/$BN
done
tar cfzv - --exclude var/register/system/havp/tmp/* $EXCLUDE . | uuencode /dev/stdout >> /mnt/backup/$BN || ERROR
cd /mnt/backup
md5sum $BN > $BN.md5
else
tar cf - --exclude var/register/system/havp/tmp/* $EXCLUDE . || ERROR
fi
date +"%d %b %Y %H:%M" > "$MP/$DB/.settings/LastBackup"
UMOUNT
May 3, 2011 at 1:48 pm #51724biGdada
Memberhow should one use such a script ?
replace /root/kerbynet.cgi/scripts/backupdb with this one ?
and how do i set backup destination ?May 3, 2011 at 3:34 pm #51725Ihyae
MemberHi (sorry for my poor English!),
this script it’s a replace of the original script.
But given that the scripts are reset to (re) boot I had to copy the script in a path which would not be reset every time you start! (eg. /Database).
As for the script I scheduled a cron once a week.
In the example I gave above, /mnt/backup is just a pendrive mounted in /mnt/backup but that is not binding.
For example, you could replace /mnt/backup with a remote destination … maybe on another server in ssh (after generating a key pair (not having to enter the pass from time to time)) by changing the script this way.
#!/bin/sh
BN=ZeroShell-`%d %b %Y %H:%M`.bak
source /etc/kerbynet.conf
function UMOUNT () {
cd /
umount $MP/$DB.AUX 2> /dev/null
if [ "$ALREADYMOUNTED" == No ] ; then
umount "$MP" && rmdir "$MP"
fi
}
function ERROR () {
cd /
echo ERROR > "$MP/$DB/.settings/LastBackup"
UMOUNT
exit 1
}
DEV="$1"
DB="$2"
COMPRESSED="$3"
WOLOGS="$4"
[ -z "$DEV" -o -z "$DB" ] && exit 1
$SCRIPTS/umountstorage >/dev/null
NODEV=${DEV:2}
LINE=`df -T -P | grep "$NODEV "`
if [ -z "$LINE" ] ; then
MP=/storage/`echo $DEV | sed -e "s///_/g"`;
mkdir -p "$MP"
mount -o rw "$DEV" "$MP" || exit 1
if [ -r /$MP/$DB.AUX ] ; then
if ! mount -oloop $MP/$DB.AUX /$MP/$DB ; then
UMOUNT
exit 2
fi
fi
ALREADYMOUNTED=No
else
MP=`echo $LINE | cut -f7 -d' '`
mount -oremount,rw "$MP" || exit 1
ALREADYMOUNTED=Yes
if [ -r /$MP/$DB.AUX ] ; then
if ! mount -oloop $MP/$DB.AUX /$MP/$DB ; then
UMOUNT
exit 2
fi
fi
fi
cd "$MP/$DB"
if ! [ -d .settings ]; then
UMOUNT
exit 3
fi
if [ "$WOLOGS" = Yes ] ; then
EXCLUDE='--exclude LOG'
else
EXCLUDE=''
fi
if [ "$COMPRESSED" == Yes ] ; then
for N in `seq 1 100` ; do
echo "$N BACKUP $DEV $DB `date` ================================================================================================" | ssh root@192.168.0.10 "cat >> /remote/destination/$BN"
done
tar cfzv - --exclude var/register/system/havp/tmp/* $EXCLUDE . | uuencode /dev/stdout | ssh root@192.168.0.10 "cat >> /remote/destination/$BN" || ERROR
else
tar cf - --exclude var/register/system/havp/tmp/* $EXCLUDE . || ERROR
fi
date +"%d %b %Y %H:%M" > "$MP/$DB/.settings/LastBackup"
UMOUNT
Another option I considered was to use samba .. up to beta 12, you can use this version: http://www.orquideadesign.com/SMB12_beta1.tar.bz2
details at this link: http://www.zeroshell.net/eng/forum/viewtopic.php?t=2209Let me know if you need help;)
bye bye,
DennisMay 9, 2011 at 9:28 am #51726biGdada
Memberthanks alot, i will try it when i finish my current project (i’m trying to make ldap clients authenticate against zeroshell, which is not that trivial 😉
November 15, 2011 at 4:04 pm #51727cufre
MemberBuongiorno , mi permetto di recuperare questo post di qualche mese fa sperando che a qualcuno capiti ancora di Farci un salto.
ho fatto un po’ di prove con lo script e devo dire che è tutto ok; avrei bisogno di qualche chiarimento del tipo: come e se posso automatizzare il mount della mia periferica usb ?, io ho aggiunto una banale riga allo scrittp del tipo:
mount /udev/sda1 /mnt/backup , ma mi chidevo se ci fosse qualcosa di più elegante tipo per individuare il nome della periferica automaticamente.
Spero di non aver scritto delle C
e ^__^.Luca.
September 6, 2013 at 6:48 am #51728best_rock
MemberI didn’t know anybody was actively working on a massbus emulator.
-
AuthorPosts
- You must be logged in to reply to this topic.