View previous topic :: View next topic |
Author |
Message |
xchris Advocate
Joined: 10 Jul 2003 Posts: 2824
|
Posted: Thu Mar 17, 2005 9:25 am Post subject: [TIP] ? - Salviamo i dati importanti di portage |
|
|
Non sapevo se postare questa stupidata che ho scritto.
In realta' e' molto semplice ma troppo spesso ho visto sul forum persone perdere /etc/fstab o /var/db/pkg...
e' uno script stupido che sara' forse utile solo ai "principianti"
(in realta' con una riga si fa lo stesso lavoro)
va bhe.. scrivo lo stesso
Code: |
#!/bin/bash
source /sbin/functions.sh
## maybe also /boot
FILES="/boot /etc /var/lib/portage /var/db/pkg /usr/local/portage"
ARCHIVE_DIR="/root"
#####
DATE=`date +"%Y%m%d-%H%M%S"`
BK_NAME="gentoo_safe.$DATE.tar.gz"
## we must be root!!
if [ ! $UID -eq 0 ]
then
eerror "You must be root!"
exit
fi
### usefull functions
boot_mounted()
{
[ `grep /boot /etc/mtab| wc -l | cut -d" " -f1` -gt 0 ] && return 1 || return 0
}
need_to_mount()
{
[ `grep /boot /etc/fstab| wc -l | cut -d" " -f1` -gt 0 ] && return 1 || return 0
}
####
boot_mounted
PREVIOUSLY_MOUNTED=$?
need_to_mount
NEED_TO_MOUNT=$?
## let's try to mount boot if we need to
if [ $NEED_TO_MOUNT -eq 1 ] && [ $PREVIOUSLY_MOUNTED -eq 0 ]
then
ebegin "Trying to mount boot"
mount /boot &>/var/log/gentoo_safe.err
eend $?
fi
ebegin "Making backup of $FILES in $ARCHIVE_DIR"
tar zcpf $ARCHIVE_DIR/$BK_NAME $FILES &>/var/log/gentoo_safe.err
eend $?
## let see if we have mounted it
boot_mounted
MOUNTED=$?
## let's try to return to initial situation
if [ $MOUNTED -eq 1 ] && [ $PREVIOUSLY_MOUNTED -eq 0 ]
then
ebegin "Unmounting /boot"
umount /boot &> /var/log/gentoo_safe.err
eend $?
fi
|
edit: versione modificata su indicazioni riportate sotto.
e' talmente banale che nessuno ha mai avuto il coraggio di postarlo
ma salva il c**o spesso!
Consiglio:salvate su partizioni diverse! _________________ while True:Gentoo()
Last edited by xchris on Fri Apr 22, 2005 3:49 pm; edited 5 times in total |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30996 Location: here
|
Posted: Thu Mar 17, 2005 9:29 am Post subject: |
|
|
E invece lo trovo utilissimo io ne ho scritto uno ma molto peggio facevo solo dei cp. Grande xchris va direttamente in /usr/local/bin _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
gutter Bodhisattva
Joined: 13 Mar 2004 Posts: 7162 Location: Aarau, Aargau, Switzerland
|
Posted: Thu Mar 17, 2005 9:33 am Post subject: |
|
|
Fatto bene bravo _________________ Registered as User #281564 and Machines #163761 |
|
Back to top |
|
|
randomaze Bodhisattva
Joined: 21 Oct 2003 Posts: 9985
|
Posted: Thu Mar 17, 2005 9:56 am Post subject: Re: [TIP] ? - Salviamo i dati importanti di portage |
|
|
Salvato.
Ma ho modificato la linea:
xchris wrote: | DATE=`date | tr " " "-"` |
Con una più civile:
Code: | date +"%Y%m%d-%H%M%S" |
...ho anche aggiunto /usr/local/portage alle directory da backuppare _________________ Ciao da me! |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30996 Location: here
|
Posted: Thu Mar 17, 2005 9:58 am Post subject: |
|
|
@randomaze: e postalo allora _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
lavish Bodhisattva
Joined: 13 Sep 2004 Posts: 4296
|
Posted: Thu Mar 17, 2005 10:00 am Post subject: Re: [TIP] ? - Salviamo i dati importanti di portage |
|
|
randomaze wrote: | [CUT]
...ho anche aggiunto /usr/local/portage alle directory da backuppare |
E io ho messo anche /boot preoccupandomi di montarla prima (togliendola da quella condizione di incertezza )
Scriptino carino xchris Grazie per il TIP _________________ minimalblue.com | secgroup.github.io/ |
|
Back to top |
|
|
xchris Advocate
Joined: 10 Jul 2003 Posts: 2824
|
Posted: Thu Mar 17, 2005 10:02 am Post subject: Re: [TIP] ? - Salviamo i dati importanti di portage |
|
|
randomaze wrote: | Salvato.
Ma ho modificato la linea:
xchris wrote: | DATE=`date | tr " " "-"` |
|
eh la pigrizia...
man date...
LOL
ahem... stavo facendo anche io il mount del boot...
mettiamoci d'accordo che cosi' ne tiriamo fuori da consigliare sempre _________________ while True:Gentoo() |
|
Back to top |
|
|
xchris Advocate
Joined: 10 Jul 2003 Posts: 2824
|
Posted: Thu Mar 17, 2005 10:33 am Post subject: |
|
|
l'ho sistemata un po' sotto vostro consiglio
vedete un po'
ciau _________________ while True:Gentoo() |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 30996 Location: here
|
Posted: Thu Mar 17, 2005 11:56 pm Post subject: |
|
|
Aggiunto ai post utilissimi sezione tips _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
luna80 Veteran
Joined: 01 Feb 2004 Posts: 1553 Location: switzerland
|
Posted: Fri Mar 18, 2005 7:32 am Post subject: |
|
|
molto utile
grazie anche da parte mia! |
|
Back to top |
|
|
hellraiser Guru
Joined: 14 Jun 2003 Posts: 431 Location: Pescara [Italy]
|
Posted: Fri Apr 22, 2005 3:23 pm Post subject: |
|
|
Quote: |
tar zcf $ARCHIVE_DIR/$BK_NAME $FILES &>/var/log/gentoo_safe.err
|
Non sarebbe meglio qualcosa del genere ??
Code: |
tar zcpf $ARCHIVE_DIR/$BK_NAME $FILES &>/var/log/gentoo_safe.err
|
che cosi preserve i permessi dei file??? _________________ Io non sono nessuno...ma nessuno è come me!
"Open Source is a good idea..." |
|
Back to top |
|
|
xchris Advocate
Joined: 10 Jul 2003 Posts: 2824
|
Posted: Fri Apr 22, 2005 3:30 pm Post subject: |
|
|
giusta osservazione...
ho fatto qualche prova e sembra comunque mantenere i permessi.
dal man non ho capito se e' di default ma immagino di si.
ciao _________________ while True:Gentoo() |
|
Back to top |
|
|
gutter Bodhisattva
Joined: 13 Mar 2004 Posts: 7162 Location: Aarau, Aargau, Switzerland
|
Posted: Fri Apr 22, 2005 3:45 pm Post subject: |
|
|
xchris wrote: |
dal man non ho capito se e' di default ma immagino di si.
ciao |
Me lo sono sempre chiesto
Comunque metterla male non fa _________________ Registered as User #281564 and Machines #163761 |
|
Back to top |
|
|
xchris Advocate
Joined: 10 Jul 2003 Posts: 2824
|
Posted: Fri Apr 22, 2005 3:50 pm Post subject: |
|
|
ok... messa a scanso di equivoci
ciao e grazie _________________ while True:Gentoo() |
|
Back to top |
|
|
hellraiser Guru
Joined: 14 Jun 2003 Posts: 431 Location: Pescara [Italy]
|
Posted: Fri Apr 22, 2005 5:41 pm Post subject: |
|
|
Figurati...è un piacere dare un piccolo contributo a questa MAGNIFICA comunita! _________________ Io non sono nessuno...ma nessuno è come me!
"Open Source is a good idea..." |
|
Back to top |
|
|
sam75 n00b
Joined: 15 Nov 2004 Posts: 59
|
Posted: Sat Apr 23, 2005 9:17 pm Post subject: |
|
|
xchris wrote: | giusta osservazione...
ho fatto qualche prova e sembra comunque mantenere i permessi.
dal man non ho capito se e' di default ma immagino di si.
ciao |
e' solo una supposizione, ma l'opzione "p" dovrebbe servire solamente per preservare i permessi quando si estraggono i files:
Dal man di tar:
Code: | -p, --same-permissions, --preserve-permissions
extract all protection information |
inoltre se si estrae come root l'opzione viene abilitata automaticamente.
Alcune brevi info si trovano anche qua: http://www.dbaoncall.net/references/ht_tar.html
EDIT:
inoltre trovi tutta la documentazione di tar su: http://www.gnu.org/software/tar/manual/html_mono/tar.htm
nella sezione 1.2 delle definizioni trovi:
Quote: | The tar program is used to create and manipulate tar archives. An archive is a single file which contains the contents of many files, while still identifying the names of the files, their owner(s), and so forth. (In addition, archives record access permissions, user and group, size in bytes, and last modification time. Some archives also record the file names in each archived directory, as well as other file and directory information.) You can use tar to create a new archive in a specified directory. |
PS: per modificare il proprietario, il gruppo e i permessi si usano le opzioni:
--owner= , --group= e --mode=
... sempre che l'implementazione di tar sia quella GNU.
ciao |
|
Back to top |
|
|
xchris Advocate
Joined: 10 Jul 2003 Posts: 2824
|
Posted: Sun Apr 24, 2005 7:22 am Post subject: |
|
|
bhe ecco svelato il mistero
grazie per la precisazione.
(effettivamente da root non ho mai messo -p)
Possiamo cmq lasciarlo nello script... cosi' a nessuno viene il dubbio
Ciao _________________ while True:Gentoo() |
|
Back to top |
|
|
gutter Bodhisattva
Joined: 13 Mar 2004 Posts: 7162 Location: Aarau, Aargau, Switzerland
|
Posted: Mon Apr 25, 2005 8:29 pm Post subject: |
|
|
xchris wrote: |
Possiamo cmq lasciarlo nello script... cosi' a nessuno viene il dubbio
|
Si meglio così _________________ Registered as User #281564 and Machines #163761 |
|
Back to top |
|
|
|