Wiki Ubuntu-it

Indice
Partecipa
FAQ
Wiki Blog
------------------
Ubuntu-it.org
Forum
Chiedi
Chat
Cerca
Planet
  • Pagina non alterabile
  • Informazioni
  • Allegati
  • Differenze per "AmministrazioneSistema/BackupDelSistema/BackupConTar"
Differenze tra le versioni 2 e 38 (in 36 versioni)
Versione 2 del 24/11/2005 14.48.26
Dimensione: 9474
Autore: BlackDesert
Commento: indice inizio traduzione
Versione 38 del 03/05/2009 18.50.43
Dimensione: 7369
Commento:
Le cancellazioni sono segnalate in questo modo. Le aggiunte sono segnalate in questo modo.
Linea 1: Linea 1:
## page was renamed from BackupDelSistema/BackupConTar
#LANGUAGE it
#format wiki
Linea 2: Linea 5:
||<tablestyle="fixed; font-size: 0.9em; width:50%; background:#F1F1ED; margin: 0 0 1em 1em;" style="padding:0.5em;">'''Indice'''[[BR]][[TableOfContents]]|| [[Indice(depth=2)]]
Linea 4: Linea 7:
'''Nota: Questo documento richiede una revisione. Use at your own risk. Si raccomanda di leggere l'intera guida prima di effettuare alcuna operazione''' = Introduzione =
Linea 6: Linea 9:
Questa guida al backup del sistema con tar è tratta da un post scritto da Heliode sul Forum Ubuntu. Questo è il thread originale della discussione: http://www.ubuntuforums.org/showthread.php?t=35087 Molti di voi probabilmente usavano Windows prima di iniziare a usare Ubuntu. Prima o poi avrete avuto la necessità di fare il backup e ripristinare il sistema. In Windows queste operazioni richiedono software proprietario per il quale avrete dovuto riavviare il sistema ed eseguire l'avvio in una sessione speciale in cui eseguire il backup o il ripristino (questo avviene con programmi come '''Norton Ghost''').
Linea 8: Linea 11:
== Introduzione == Sicuramente vi sarete chiesti per quale motivo non fosse possibile semplicemente salvare l'intera unità `C:\` in un archivio `*.zip`. Quest'operazione è impossibile perché in Windows ci sono molti file che non possono essere copiati o sovrascritti mentre sono in uso dal sistema. Per questo, è necessario un software specifico.
Linea 10: Linea 13:
Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system! In Ubuntu non vi è alcuna necessità di usare programmi come '''Ghost''' per creare un backup dell'intero sistema. Utilizzare '''Ghost''' su sistemi con un filesystem diverso da '''ext2''' può causare degli errori: '''ext3''', il filesystem standard delle partizioni Ubuntu, è considerato da '''Ghost''' come un formato '''ext2''' difettoso.
Linea 12: Linea 15:
Most of you have probably used Windows before you started using Ubuntu. During that time you might have needed to backup and restore your system. For Windows you would need proprietary software for which you would have to reboot your machine and boot into a special environment in which you could perform the backing-up/restoring (programs like Norton Ghost).
During that time you might have wondered why it wasn't possible to just add the whole c:\ to a big zip-file. This is impossible because in Windows, there are lots of files you can't copy or overwrite while they are being used, and therefore you needed specialized software to handle this.
= Il backup =
Linea 15: Linea 17:
Well, I'm here to tell you that those things, just like rebooting, are Windows Crazy Things (tm). There's no need to use programs like Ghost to create backups of your Ubuntu system (or any Linux system, for that matter). In fact; using Ghost might be a very bad idea if you are using anything but ext2. Ext3, the default Ubuntu partition, is seen by Ghost as a damaged ext2 partition and does a very good job at screwing up your data. Con Ubuntu è possibile eseguire un backup con gli stessi strumenti utilizzati per archiviare o comprimere ogni altro file: '''tar'''.
Linea 17: Linea 19:
== Backing-up == Per eseguire un backup dell'intero sistema partendo dalla directory root `/`, è necessario utilizzare il comando [:AmministrazioneSistema/Sudo:sudo].
Linea 19: Linea 21:
"What should I use to backup my system then?" might you ask. Easy; the same thing you use to backup/compress everything else; TAR. Unlike Windows, Linux doesn't restrict root access to anything, so you can just throw every single file on a partition in a TAR file!

To do this, become root with

{{{
sudo su
}}}

and go to the root of your filesystem (we use this in our example, but you can go anywhere you want your backup to end up, including remote or removable drives.)

{{{
Spostarsi nella directory `/`: {{{
Linea 33: Linea 25:
Now, below is the full command I would use to make a backup of my system:

{{{
tar -cvpzf /backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
Il comando da utilizzare per fare il backup del sistema è: {{{
sudo tar -cvpzf /backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
Linea 39: Linea 29:
Now, lets explain this a little bit:
 * 'tar' is the program used to do a backup
 * c - create a new backup archive
 * v - verbose mode, tar will print what it's doing to the screen
 * p - preserve permissions, keeps all file permissions the same
 * z - compress the backup file with 'gzip' to make it smaller
 * f <filename> - specifies where to store the backup, /backup.tgz is the file used in this example
 * Now come the directories we want to exclude. We don't want to backup everything since some dirs aren't very useful to include. Also make sure you don't include the file itself, or else you'll get weird results. You might also not want to include the /mnt folder if you have other partitions mounted there or you'll end up backing those up too. Also make sure you don't have anything mounted in /media (i.e. don't have any cd's or removable media mounted). Either that or exclude /media.
 * After all of the options is the directory we want to backup. Since we want to backup everything we use / for the root directory
Vediamo ora di spiegare questa sintassi:
Linea 49: Linea 31:
If you want to exclude all other filesystems you can use the 'l' option instead of --exclude. The above command would thus be:  * '''tar''': è il programma necessario a fare il backup
 * '''c''': crea un nuovo archivio di backup
 * '''v''': modalità ''verbose'', '''tar''' restituisce sullo schermo una descrizione delle operazioni in corso
 * '''p''': mantiene i permessi di tutti i file
 * '''z''': comprime il file di backup con '''gzip''' per renderlo più piccolo
 * '''f <nomefile>''': specifica dove salvare il backup, `/backup.tgz` è il file utilizzato in questo esempio
 * Di seguito vengono indicate tutte le directory da escludere dal backup. Non è necessario fare il backup di tutto quanto, alcune directory non sono indispensabili. Assicurarsi di non includere anche il file di backup stesso, altrimenti si potrebbero avere strani risultati. È anche consigliato non includere le cartella `/mnt` e `/media`: nel caso ci siano altre partizioni montate, si farebbe il backup anche di quelle.
 * Dopo tutte le opzioni c'è le directory di cui vogliamo fare il backup. In questo caso è indicato `/` per salvare quasi tutto.
Linea 51: Linea 40:
{{{
tar -cvpzlf /backup.tgz --exclude=/lost+found --exclude=/backup.tgz /
}}}
Digitato il comandi, premere '''Invio''' per avviare il backup. Tutto il procedimento impiegherà un po' di tempo.
Verrà quindi creato il file `backup.tgz`, probabilmente molto grande, all'interno della directory `/` del file system. Ora, è possibile copiarlo su un DVD o spostarlo in un altro computer.
Linea 55: Linea 43:
EDIT: kvidell suggests on the forum thread that we also exclude the /dev directory. I have other evidence that says it is very unwise to do so though.

Well, if the command agrees with you, hit enter (or return, whatever) and sit back & relax. This might take a while.

Afterwards you'll have a file called backup.tgz, which is probably pretty large, in the root of your filesytem. Now you can burn it to DVD or move it to another machine; whatever you like!

attachment:IconsPage/IconWarning3.png WARNING: Files that are bigger than 2GB (a little less actually) are not supported by ISO9660 and may or may not be restorable. So don't simply burn a DVD with a huge .iso file on it. Split it up using the command split (see man page) or use a different way to get it onto the DVD. One possiblity (untested) is the following:

{{{
sudo tar --create --bzip2 --exclude /tmp --one-file-system --sparse / | growisofs -use-the-force-luke -Z /dev/hda=/proc/self/fd/0
}}}

Note that this only backs up one file system. You might want to use --exclude instead of --one-file-system to filter out the stuff you don't want backed up. This assumes your DVD drive is /dev/hda. This will not create a mountable DVD. To restore it you will reference the device file:

{{{
sudo tar --extract --bzip2 --file /dev/hda
}}}

EDIT2:
At the end of the process you might get a message along the lines of 'tar: Error exit delayed from previous errors' or something, but in most cases you can just ignore that.

Alternatively, you can use Bzip2 to compress your backup. This means higher compression but lower speed. If compression is important to you, just substitute
the 'z' in the command with 'j', and give the backup the right extension.
That would make the command look like this:

{{{
È possibile anche utilizzare '''bzip2''' per comprimere il file di backup. Questo porta un maggiore compressione a discapito di una velocità minore. Sostituire nel comando precedente l'opzione '''z''' con '''j''' e modificare l'estensione del file di backup: {{{
Linea 84: Linea 47:
=== Backup over network === == Aggiungere la data al file di backup ==
Linea 86: Linea 49:
If the filesystem is low on space and you can't mount another filesystem to store the backup file on it is
possible to use netcat to trasfer the backup.
Al nome del file di backup è possibile aggiungere la data di esecuzione dello stesso; a tale scopo è sufficiente aggiungere la seguente dicitura al comando di backup:
{{{
`date +%d-%m-%Y`
}}}
Linea 89: Linea 54:
On the receiving end you'll setup netcat to write the backup file like this: Il comando finale sarà simile al seguente:
{{{
tar -cvpjf /backup-`date+%d-%m-%Y`.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /
}}}
Linea 91: Linea 59:
{{{ Il precedente comando aggiungerà al nome del file una data in formato «giorno-mese-anno».

== Backup attraverso la rete ==

Se il vostro disco fisso non ha abbastanza spazio o non è possibile montarne un altro in cui salvare il backup, è possibile usare '''netcat''' per spostare il file di backup.

Dalla parte del ricevente, impostare '''netcat''' in modo da scrivere il backup in questo modo: {{{
Linea 95: Linea 69:
Then you pipe the tar command without the 'f' flag through netcat on the sending end like this:

{{{
tar -cvpj <all those other options> / | nc -q 0 <receiving host> 1024
Quindi, mettere in ''pipe'' il comando per eseguire il backup, senza il flag '''f''', con '''netcat''' in questo modo: {{{
tar -cvpj <tutte le altre opzioni> / | nc -q 0 <host di ricezione> 1024
Linea 101: Linea 73:
In the above commands 1024 is just a random portnumber, anything from 1024 and up should work. ||<tablestyle="text-align: justify; width:100%; " style="border:none;" 5%>[[Immagine(Icone/Piccole/note.png,,center)]] ||<style="padding:0.5em; border:none;">''1024 è un numero di porta qualsiasi, un numero da 1024 in su dovrebbe andare bene.'' ||
Linea 103: Linea 75:
If all goes well the backup will be piped through the network without touching the filesystem being read.
With a really fast network this could actually be faster then writing the backup file back to disk.
Se tutto funziona correttamente il backup sarà inviato in ''pipe'' attraverso la rete. Con una rete abbastanza veloce, potrebbe risultare più veloce dello scrivere il file sul disco.
Linea 106: Linea 77:
A variation (which I just dreamed up, so I can't testify on its reliability) on the above is this command: = Ripristinare =
Linea 108: Linea 79:
{{{
tar -cvpj <all those other options> / | ssh <remote host> "cat > backup.tar.bz2"
||<tablestyle="text-align: justify; width:100%; " style="border:none;" 5%>[[Immagine(Icone/Piccole/warning.png,,center)]] ||<style="padding:0.5em; border:none;">'''Prestare molta attenzione alle istruzioni seguenti, in caso di errori si possono sovrascrivere file importanti per il sistema. Il comando seguente sovrascriverà tutti i file del sistema con quelli presenti nell'archivio di backup.''' ||

Per ripristinare il backup non c'è bisogno di entrare in una modalità speciale del sistema operativo, è possibile farlo con il sistema in esecuzione. Nel caso in cui non si riesca ad accedere al sistema, è possibile utilizzare un D ''live'' per ottenere gli stessi risultati.

Potete rimuovere qualsiasi file dal sistema mentre questo è in esecuzione, con tutto ciò che questo comporta al successivo riavvio.

 0. Copiare il file di backup nella directory `/`

 0. Per eseguire il ripristino, digitare: {{{
sudo tar -xvpzf /backup.tgz -C /
Linea 112: Linea 91:
== Restoring ==  0. Nel caso in cui sia stato utilizzato '''bunzip2''', digitare: {{{
tar -xvpjf backup.tar.bz2 -C /
}}} Alcune opzioni:
  * '''x''': serve per estrarre i file nell'archivio
  * '''-C <directory>''': serve per spostarsi in una specifica directory, in questo caso `/`, prima di estrarre i file.
Linea 114: Linea 97:
attachment:IconsPage/IconWarning3.png Warning: Please, for goodness sake, be careful here. If you don't understand what you are doing here you might end up overwriting stuff that is important to you, so please take care!

Well continue with our example from the previous chapter which created the file backup.tgz in the root directory.

Once again, make sure you are root and that you and the backup file are in the root of the filesystem.

One of the beautiful things of Linux is that this will even work on a running system; no need to screw around with boot-cd's or anything. Of course, if you've rendered your system unbootable you might have no choice but to use a live cd but the results are the same. You can even remove every single file of a Linux system while it is running with one command. I'm not giving you that command though!

Well, back on-topic.
This is the command that I would use:

{{{
tar -xvpzf /backup.tgz -C /
}}}

Or if you used bz2;

{{{
tar -xvpjf backup.tar.bz2 -C /
}}}

The x option tells tar to extract the file. The -C <directory> option tells tar to change to a specific directory ( / in this example ) before extracting.

attachment:IconsPage/IconWarning3.png WARNING: this will overwrite every single file on your partition with the one in the archive!

Just hit enter/return/your brother/whatever and watch the fireworks. Again, this might take a while. When it is done, you have a fully restored Ubuntu system! Just make sure that, before you do anything else, you re-create the directories were excluded ( /proc, /lost+found, /mnt, /sys, etc.).

{{{
 0. Premere '''Invio''' per avviare il ripristino. La procedura potrebbe impiegare un po' di tempo. Al termine il sistema sarà completamente ripristinato. Assicurarsi, prima di fare qualsiasi altra cosa, di ricreare le directory escluse durante il backup nel caso siano state compromesse (`/proc`, `/lost+found`, `/mnt`, `/sys`...): {{{
Linea 145: Linea 101:
And when you reboot, everything should be the way it was when you made the backup! Al prossimo riavvio tutto dovrebbe essere come prima di effettuare il backup.
Linea 147: Linea 103:
=== GRUB restore === = Programmare il backup con cron =
Linea 149: Linea 105:
Now, if you want to move your system to a new harddisk or if you did something nasty to your GRUB (like, say, install Windows), You'll also need to reinstall GRUB.
There are several very good howto's on how to do that here on this forum, so i'm not going to reinvent the wheel. Instead, take a look [http://www.ubuntuforums.org/showthread.php?t=24113&highlight=grub+restore here] (forum) or here: RecoveringUbuntuAfterInstallingWindows
L'esecuzione di queste operazioni può essere programmata, e quindi resa automatica, con il comando [:AmministrazioneSistema/Cron:cron].
Linea 152: Linea 107:
On the forum thread, there are a couple of methods proposed. I personally recommend the second one, posted by remmelt, since that has always worked for me. = Ulteriori risorse =
Linea 154: Linea 109:
Well that's it! I hope it was helpful!

== Other Methods ==

You might also want to check out these backup programs which will help you to make automated backups of your system:
 * [http://www.partimage.org/ Partimage]
 * [http://www.mondorescue.org/ Mondo Rescue]

CategoryDocumentation CategoryCleanup

See the full discussion in this thread on the Ubuntu forums. http://www.ubuntuforums.org/showthread.php?t=70566
 * [:AmministrazioneSistema/BackupDelSistema:Backup del sistema]
 * [:Amanda:Guida al tool di backup Amanda]
 * [http://www.ubuntuforums.org/showthread.php?t=35087]
 * Documento originale: [wiki:Ubuntu/BackupYourSystem BackupYourSystem]
----
CategoryAmministrazione CategoryDaRevisionare
## RevisioneStilistica

BR Indice(depth=2)

Introduzione

Molti di voi probabilmente usavano Windows prima di iniziare a usare Ubuntu. Prima o poi avrete avuto la necessità di fare il backup e ripristinare il sistema. In Windows queste operazioni richiedono software proprietario per il quale avrete dovuto riavviare il sistema ed eseguire l'avvio in una sessione speciale in cui eseguire il backup o il ripristino (questo avviene con programmi come Norton Ghost).

Sicuramente vi sarete chiesti per quale motivo non fosse possibile semplicemente salvare l'intera unità C:\ in un archivio *.zip. Quest'operazione è impossibile perché in Windows ci sono molti file che non possono essere copiati o sovrascritti mentre sono in uso dal sistema. Per questo, è necessario un software specifico.

In Ubuntu non vi è alcuna necessità di usare programmi come Ghost per creare un backup dell'intero sistema. Utilizzare Ghost su sistemi con un filesystem diverso da ext2 può causare degli errori: ext3, il filesystem standard delle partizioni Ubuntu, è considerato da Ghost come un formato ext2 difettoso.

Il backup

Con Ubuntu è possibile eseguire un backup con gli stessi strumenti utilizzati per archiviare o comprimere ogni altro file: tar.

Per eseguire un backup dell'intero sistema partendo dalla directory root /, è necessario utilizzare il comando [:AmministrazioneSistema/Sudo:sudo].

Spostarsi nella directory /:

cd /

Il comando da utilizzare per fare il backup del sistema è:

sudo tar -cvpzf /backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

Vediamo ora di spiegare questa sintassi:

  • tar: è il programma necessario a fare il backup

  • c: crea un nuovo archivio di backup

  • v: modalità verbose, tar restituisce sullo schermo una descrizione delle operazioni in corso

  • p: mantiene i permessi di tutti i file

  • z: comprime il file di backup con gzip per renderlo più piccolo

  • f <nomefile>: specifica dove salvare il backup, /backup.tgz è il file utilizzato in questo esempio

  • Di seguito vengono indicate tutte le directory da escludere dal backup. Non è necessario fare il backup di tutto quanto, alcune directory non sono indispensabili. Assicurarsi di non includere anche il file di backup stesso, altrimenti si potrebbero avere strani risultati. È anche consigliato non includere le cartella /mnt e /media: nel caso ci siano altre partizioni montate, si farebbe il backup anche di quelle.

  • Dopo tutte le opzioni c'è le directory di cui vogliamo fare il backup. In questo caso è indicato / per salvare quasi tutto.

Digitato il comandi, premere Invio per avviare il backup. Tutto il procedimento impiegherà un po' di tempo. Verrà quindi creato il file backup.tgz, probabilmente molto grande, all'interno della directory / del file system. Ora, è possibile copiarlo su un DVD o spostarlo in un altro computer.

È possibile anche utilizzare bzip2 per comprimere il file di backup. Questo porta un maggiore compressione a discapito di una velocità minore. Sostituire nel comando precedente l'opzione z con j e modificare l'estensione del file di backup:

tar -cvpjf /backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

Aggiungere la data al file di backup

Al nome del file di backup è possibile aggiungere la data di esecuzione dello stesso; a tale scopo è sufficiente aggiungere la seguente dicitura al comando di backup:

`date +%d-%m-%Y`

Il comando finale sarà simile al seguente:

tar -cvpjf /backup-`date+%d-%m-%Y`.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

Il precedente comando aggiungerà al nome del file una data in formato «giorno-mese-anno».

Backup attraverso la rete

Se il vostro disco fisso non ha abbastanza spazio o non è possibile montarne un altro in cui salvare il backup, è possibile usare netcat per spostare il file di backup.

Dalla parte del ricevente, impostare netcat in modo da scrivere il backup in questo modo:

nc -l -p 1024 > backup.tar.bz2

Quindi, mettere in pipe il comando per eseguire il backup, senza il flag f, con netcat in questo modo:

tar -cvpj <tutte le altre opzioni> / | nc -q 0 <host di ricezione> 1024

Immagine(Icone/Piccole/note.png,,center)

1024 è un numero di porta qualsiasi, un numero da 1024 in su dovrebbe andare bene.

Se tutto funziona correttamente il backup sarà inviato in pipe attraverso la rete. Con una rete abbastanza veloce, potrebbe risultare più veloce dello scrivere il file sul disco.

Ripristinare

Immagine(Icone/Piccole/warning.png,,center)

Prestare molta attenzione alle istruzioni seguenti, in caso di errori si possono sovrascrivere file importanti per il sistema. Il comando seguente sovrascriverà tutti i file del sistema con quelli presenti nell'archivio di backup.

Per ripristinare il backup non c'è bisogno di entrare in una modalità speciale del sistema operativo, è possibile farlo con il sistema in esecuzione. Nel caso in cui non si riesca ad accedere al sistema, è possibile utilizzare un D live per ottenere gli stessi risultati.

Potete rimuovere qualsiasi file dal sistema mentre questo è in esecuzione, con tutto ciò che questo comporta al successivo riavvio.

  1. Copiare il file di backup nella directory /

  2. Per eseguire il ripristino, digitare:

    sudo tar -xvpzf /backup.tgz -C /
  3. Nel caso in cui sia stato utilizzato bunzip2, digitare:

    tar -xvpjf backup.tar.bz2 -C /
    Alcune opzioni:
    • x: serve per estrarre i file nell'archivio

    • -C <directory>: serve per spostarsi in una specifica directory, in questo caso /, prima di estrarre i file.

  4. Premere Invio per avviare il ripristino. La procedura potrebbe impiegare un po' di tempo. Al termine il sistema sarà completamente ripristinato. Assicurarsi, prima di fare qualsiasi altra cosa, di ricreare le directory escluse durante il backup nel caso siano state compromesse (/proc, /lost+found, /mnt, /sys...):

    mkdir /proc /lost+found /mnt /sys

Al prossimo riavvio tutto dovrebbe essere come prima di effettuare il backup.

Programmare il backup con cron

L'esecuzione di queste operazioni può essere programmata, e quindi resa automatica, con il comando [:AmministrazioneSistema/Cron:cron].

Ulteriori risorse


CategoryAmministrazione CategoryDaRevisionare