[SOLVED] Cron Backup

Home Page Forums Network Management ZeroShell [SOLVED] Cron Backup

This topic contains 5 replies, has 0 voices, and was last updated by  Ihyae 5 years, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #42970

    Ihyae
    Member

    Salve 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,
    Dennis

    #51723

    Ihyae
    Member

    Così 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
    #51724

    biGdada
    Member

    how should one use such a script ?
    replace /root/kerbynet.cgi/scripts/backupdb with this one ?
    and how do i set backup destination ?

    #51725

    Ihyae
    Member

    Hi (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=2209

    Let me know if you need help;)
    bye bye,
    Dennis

    #51726

    biGdada
    Member

    thanks 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 😉

    #51727

    cufre
    Member

    Buongiorno , 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.

    #51728

    best_rock
    Member

    I didn’t know anybody was actively working on a massbus emulator.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.