Re: Howto: Backup and restore your system!
Quote:
Originally Posted by
Marius Cloete
Hi all,
Here is a shell I have put together from this post. I am not a guru on shell scripts this was put together with the help of google search :P.
Feel free to comment and/or change it.
I saved it as backupAndRestore.sh and you can run it as follows
sudo ./backupAndRestore.sh
enjoy
Code:
#!/bin/bash
S1='b'
S2='y'
echo "Please enter b for backup or r for restore:"
read action
if [ $action = $S1 ]; then
echo "These Directories will be excluded:"
echo -e "\033[1m\033[32m /proc /lost+found */backup.tgz /mnt /sys /dev"
echo -e "\033[0m"
echo "To chance these values edit this shell"
echo "continue (y/n):"
read action
if [ $action = $S2 ]; then
echo "Backing up PC ~ timestamp " ;date
tar cpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=*/backup.tgz --exclude=/mnt --exclude=/sys /
fi
else
echo -e "\033[1m\033[31mWARNING: this will overwrite every single file on your partition with the one in the archive!"
echo -e "\033[0m"
echo "Please enter name and location of the archive to restore:"
read fileName
echo "You are about to restore $fileName do you want to continue?(y/n)"
read action
echo -e "\033[1m\033[47mJust sit back and watch the fireworks.This might take a while. When it is done, you have a fully restored Ubuntu system!"
sleep 5
echo "start"
if [ $action = $S2 ]; then
tar xvpfz $fileName -C /
echo "Creating excluded directories"
#Just to make sure that all excluded directories are re-created
mkdir /proc
mkdir /lost+found
mkdir /mnt
mkdir /sys
fi
fi
echo -e "\033[0m"
Thanks it worked great for me! One thing that you'll have to do is to modify your grub or grub2 after you restore. Fast and easy way to back up or migrate to another machine.
Cheers!
Re: Howto: Backup and restore your system!
Is there a way for me to back it up on this hard drive and then install it on another hard drive. My HD is taking a crap so that's why i'm asking.
Re: Howto: Backup and restore your system!
Quote:
Originally Posted by
nick_geetar
Is there a way for me to back it up on this hard drive and then install it on another hard drive. My HD is taking a crap so that's why i'm asking.
best way I can think of would be to backup your drive using the script then copy it on a flash stick or network drive. Then install ubuntu on your new HDD then locate you backup file (flash or network) and then run the restore.
Re: Howto: Backup and restore your system!
If you're dealing with a tower with an extra bay, you might consider putting the new HDD in that bay, installing Ubuntu on it. If you create the backup on your old drive before making the new one the master, you should be able to run Ubuntu on your new drive with your old drive mounted. It should be straight-forward from there.
Re: Howto: Backup and restore your system!
Great thread, Heliode. Thanks for writing out your guide.
Re: Howto: Backup and restore your system!
Why don't you use Sbackup? It is awesome and easy to use...
Re: Howto: Backup and restore your system!
this is gr8.
As due to large number of power cuts in my area, many times due to improper shut down my system fails to restart and i have to re-install the whole operating system again and again.
Re: Howto: Backup and restore your system!
Hi,
I have been using the tar utility like described in the first post of this post to backup my Ubuntu system - with success.
But now I have moved to a new harddrive with a new partition order and I installed Ubuntu 9.10 which uses grub2, but apperently my backup Ubuntu version used "grub1" (although the system itself is also Ubunut 9.10).
Grub2' boot menu shows up fine, but when I try to start Ubuntu, it shows the starting screen, and then hangs.
My new partition layout looks like this:
/sda1 (NTFS): Windows 7 boot loader
/sda2 (NTFS)
/sda5 (ext3): Ubuntu
/sda6 (swap)
Do you have any hints how to fix this?
Re: Howto: Backup and restore your system!
Quote:
Originally Posted by
Heliode
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!!
Great, but do I need to re-create those directories? Files will be overwritten, but the excluded directories won't be removed, will they?
Thanks
Re: Howto: Backup and restore your system!
I could be wrong, but I don't believe the tar file contains information about what directories were excluded. I also don't think it's accurate to say every file is overwritten. In my experience, using tar extract only overwrites files in the tar file already reflected in the destination directory, and creates the files in the tar file not yet destination directory.
That would mean the excluded directories you've listed would still exist.
If you don't do a clean install before restoring, though, you might still have old files not in your backup hanging around.