www.zeroshell.org Forum Index www.zeroshell.org
Linux Distribution for server and embedded devices
 
 SearchSearch  RegisterRegister  UsergroupsUsergroups 
 ProfileProfile  Log inLog in  Log in to check your private messagesPrivate Message 

[SOLVED] Cron Backup

 
Post new topic   Reply to topic    www.zeroshell.org Forum Index -> ZeroShell
View previous topic :: View next topic  
Author Message
Ihyae



Joined: 29 Apr 2011
Posts: 3

PostPosted: Fri Apr 29, 2011 2:45 pm    Post subject: [SOLVED] Cron Backup Reply with quote

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:

Code:

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:

Code:

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


Last edited by Ihyae on Mon May 02, 2011 1:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ihyae



Joined: 29 Apr 2011
Posts: 3

PostPosted: Mon May 02, 2011 1:11 pm    Post subject: Edited script Reply with quote

Così funziona, il backup viene fatto su un mount point.. il device è USB ma funziona anche in ssh senza problemi, basta cambiare la stringa!

Code:

#!/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
Back to top
View user's profile Send private message
biGdada



Joined: 30 Apr 2011
Posts: 8

PostPosted: Tue May 03, 2011 1:48 pm    Post subject: Reply with quote

how should one use such a script ?
replace /root/kerbynet.cgi/scripts/backupdb with this one ?
and how do i set backup destination ?
Back to top
View user's profile Send private message
Ihyae



Joined: 29 Apr 2011
Posts: 3

PostPosted: Tue May 03, 2011 3:34 pm    Post subject: How to: Cron Backup Reply with quote

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.

Code:

#!/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
Back to top
View user's profile Send private message
biGdada



Joined: 30 Apr 2011
Posts: 8

PostPosted: Mon May 09, 2011 9:28 am    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message
cufre



Joined: 21 Feb 2011
Posts: 5

PostPosted: Tue Nov 15, 2011 4:04 pm    Post subject: piccole info Reply with quote

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.
Back to top
View user's profile Send private message
best_rock



Joined: 06 Sep 2013
Posts: 2

PostPosted: Fri Sep 06, 2013 6:48 am    Post subject: Reply with quote

I didn't know anybody was actively working on a massbus emulator.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.zeroshell.org Forum Index -> ZeroShell All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group