Sida 1 av 1
Hur gör man enb backup ?
Postat: 03 jun 2008, 21:18
av leakim
Jag vill prova att göra back-ups av mitt Ubuntu-system.
Hur gör man??
Har läst att om man tex kör:
$ cd /home
$ sudo tar czvf /tmp/home_dir_backup.tdz *
Skall få en backup på allt som finns i min /home i mappen tmp/med filnamn home_dir_backup.tgz som jag sedan skulle kunna bränna eller lagra på en extern usb-disk.
Men jag får felmedelande enl bilagt.
michael@michael-desktop:~$ cd /home
michael@michael-desktop:/home$ sudo tar czvf /temp/home_dir_backup.tgz *
[sudo] password for michael:
michael/
michael/.nautilus/
michael/.nautilus/saved-session-ZVYNBU
tar: /temp/home_dir_backup.tgz: Funktion "open" misslyckades: Filen eller katalogen finns inte
tar: Felet kan inte åtgärdas, avslutar nu
michael/.nautilus/saved-session-5YC6BU
michael/.nautilus/saved-session-HDCYBU
michael/.nautilus/saved-session-WQWEBU
michael@michael-desktop:/home$
Vad är fel.
Jag har ingen susning om komandospråket som man använder i Ubuntun

Re: Hur gör man enb backup ?
Postat: 03 jun 2008, 22:44
av paganini
Jag kör en komplett backup på Ubuntu med nedanstående kommandon i en terminal. fungerar jättefint. När sedan har behövt installera om, så installerar jag orginalskivan och efter det så använder jag backupen och på så sätt återställer allt som det var vid sista backupkörningen (alla inställningar, alla mail med konton och lösenord, mm mm). Gör det en gång i veckan å det tar ca en halvtimme. se nedan:
kopieara bara av de röda kommandon och klistra in i terminalen
To do a comolete backupt, become root with
Code:
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.)
Code:
cd /
Now, below is the full command I would use to make a backup of my system:
Code:
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
Now, lets explain this a little bit.
The 'tar' part is, obviously, the program we're going to use.
'cvpfz' are the options we give to tar, like 'create archive' (obviously),
'preserve permissions'(to keep the same permissions on everything the same), and 'gzip' to keep the size down.
Next, the name the archive is going to get. backup.tgz in our example.
Next comes the root of the directory we want to backup. Since we want to backup everything; /
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.
EDIT : kvidell suggests below 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 in the root of your filessytem, which is probably pretty large. Now you can burn it to DVD or move it to another machine, whatever you like!
2: Restoring
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, we'll just continue with our example from the previous chapter; the file backup.tgz in the root of the partition.
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'll work even 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:
Code:
tar xvpfz backup.tgz -C /
Or if you used bz2;
Code:
tar xvpfj backup.tar.bz2 -C /
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 you excluded:
Code:
mkdir proc
mkdir lost+found
mkdir mnt
mkdir sys
etc...
And when you reboot, everything should be the way it was when you made the backup!
Radera i rooten: rm exemple.tgz
Det bli vissrligen en stor fil, i mitt fall ca 4GB, men värt då det hela är så smidigt. När backenupen är tillbaks, är det bara att fortsätta som om inget hänt.
Lycka till
Michael
Re: Hur gör man enb backup ?
Postat: 04 jun 2008, 21:18
av leakim
Paganini
Tack för ditt svar.
Jag kommer att studera det och göra ett försök när jag törs.
Min installation av Ubuntu ligger på min slav D:\ (NTFS) Det betyder väl att jag skall Restora enligt:
tar xvpfz backup.tgz -D /
Undring.? Var hittar man den information du givit mig i detta fall.
Kan jag söka info om annat där??
Mvh
Michael
Re: Hur gör man enb backup ?
Postat: 04 jun 2008, 21:45
av KiviE
leakim skrev:Min installation av Ubuntu ligger på min slav D:\ (NTFS) Det betyder väl att jag skall Restora enligt:
tar xvpfz backup.tgz -D /
Nej du ska ändå använda flaggan
-C. -C betyder att när filen ska packas upp så ska den gå till
/ och packa upp därifrån.
leakim skrev:Undring.? Var hittar man den information du givit mig i detta fall.
Kan jag söka info om annat där??
Antar att han har fått det från
http://ubuntuforums.org/showthread.php?t=35087
Och ja du kan söka info om annat där, är det engelska ubuntu forumet.