Backup and restore your system!

Howto: Backup and restore your system!

Hi, and welcome to the Heliode guide to successful backing-up and restoring of a Linux system!

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.

Well, I’m here to tell you that those things, just like rebooting, are Windows CrazyThings ™. 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.

1: Backing-up

“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

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!

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:

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

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!

2.1: GRUB restore
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 here:

http://www.ubuntuforums.org/showthre…t=grub+restore

There are a couple of methods proposed. I personally recommend the second one, posted by remmelt, since that has always worked for me.

Well that’s it! I hope it was helpful!
As always, any feedback is appreciated!


Last edited by aysiu; November 29th, 2006 at 01:15 AM.. Reason: Moved slash to end of command by popular vote
  • Comments Off

Install KDE in debian

Install KDE in debian

#apt-get install x-window-system-core kde

You’ll probably also want to install KDM, for the KDE-style login screen.

#apt-get install kdm

Starting KDE

To start KDE, type

#startkde

you may need to start X-Server if it is not running, to start it run

#startx

  • Comments Off

lspci

install pciutils

  • Comments Off

OpenVZ Web Panel


OpenVZ Web Panel is a GUI web-based frontend for controlling of the hardware and virtual servers with the OpenVZ virtualization technology.

Announcements

  • 2011/04/17 - OpenVZ Web Panel 2.0 is available! It’s a major release. Most important features are Remote API, IP addresses management, virtual servers migration. Also a lot of bugfixes were made. Thanks to all the people who helped in release preparation. See ChangeLog for more details.

Demo

Demonstration of web panel’s user interface is below:

Installation

The most simple way to install OpenVZ Web Panel is to run the following command (under root):

wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

After installation Panel should be available by the following URL:

http://<your-host>:3000

Default administrator’s credentials are: admin/admin. Don’t forget to change default password.

  • Comments Off

I have a tiny embedded server (acrosser model) Intel Celeron with only 400MHz and 512MB Mem total. Before I upgraded debian to squeeze I used Xen, now its time to use OpenVZ.

Reasons:
- My tiny hardware:)
- Container virtualization – I can use more virtual machines
- Less memory usage – Container cannot boot

OpenVZ kernel and the vzctl and vzquota packages are available in the Debian repositories, so we can install them as follows:

1
aptitude update ; aptitude install linux-image-openvz-686 vzctl vzquota

Create a symlink from /var/lib/vz to /vz to provide backward compatibility and better usage:

1
ln -s /var/lib/vz /vz

Open vim /etc/sysctl.conf and make sure that you have the following settings in it:

1
2
3
4
5
6
7
8
9
10
11
[...]
net.ipv4.conf.all.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.ip_forward = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.eth0.proxy_arp = 1
[...]

View now your current config:

1
sysctl -p

Now its time to reboot and start your new kernel:

1
 reboot

After reboot you should see your fresh installed kernel:

1
2
nibbler ~ # uname -a
Linux nibbler 2.6.32-5-openvz-686 #1 SMP Tue Mar 8 23:30:33 UTC 2011 i686 GNU/Linux

Now we create our fist container, to do this we need a working template. A lot of templates can be founded here.
Of course you can create your own template. I describe it later:)

Choose one and download it to your template directory:

1
2
cd /vz/template/cache
wget http://download.openvz.org/template/precreated/contrib/debian-6.0-i386-minimal.tar.gz

After download don’t extract it!

1
2
3
4
5
6
7
8
vzctl create 01 –ostemplate debian-6.0-i386-minimal
vzctl set 01 –ipadd 192.168.1.77 –save
vzctl set 01 –nameserver 192.168.1.1 –save
vzctl set 01 –hostname gitcher –save
vzctl start 01
ping 192.168.1.77
vzctl exec 01 passwd
vzctl enter 01

Some basic commands:

1
2
3
4
5
6
7
8
9
10
vzlist
vzlist -a
vzctl stop 01
vzctl start 01
vzctl restart 01
vzctl status 01
vzctl umount 01
vzctl destroy 01
allocate disk space
vzctl set 01 –diskspace “10000000:11000000″ –save

UPDATE 30.06.2011 – Fix the default gateway
After VE creating the default gateway will be: 192.0.2.1 but whit is not my network.
You can set the default gateway in: /etc/vz/dists/scripts/functions

1
2
vim /etc/vz/dists/scripts/functions
FAKEGATEWAY=192.168.1.1
  • Comments Off

This tutorial will show how to set samba to allow read-only file sharing for your LAN computers as guest (without be prompted for a password).

Because users won’t be prompted for a user/password, this tutorial is meant to be installed in a LAN where all host are to be trusted.

There is many advantages of sharing files in a LAN. For instance, when you have a multimedia box (playing music, movies….) it is great to be able to access the music on that box from any machines in your LAN.

Let’s get started. In the first place, you need to have samba installed.

$sudo apt-get install samba

Because we are going to make samba security insecure, make sure only your local network can access samba service. To do so, open and edit/etc/samba/smb.conf

$sudo vi /etc/samba/smb.conf

and set interfaces to lo and your local network interface. In my case: eth1.

interfaces = lo eth1
bind interfaces only = true

Now, it is time to smoothen samba default security by changing the security variable: security and make sure it is set to share instead ofuser and that guest account is enabled:

security = share
...
...
guest account = nobody

Now, we can create a share to be accessible to guest users:

[Guest Share]
        comment = Guest access share
        path = /path/to/dir/to/share
        browseable = yes
        read only = yes
        guest ok = yes

You can now test that your configuration is good using testparm:

$ testparm

If everything is fine, it is time to reload samba service to have your new configuration taken into account:

$sudo /etc/init.d/samba reload

That’s it, anybody in your LAN can now access your share.

  • Comments Off

Time

Mp3

Msn status

  • manon2029@hotmail.com is

Chat with Meeh

Donate

    If you find an article useful, then please make a donation.

หมวดหมู่

UserOnline

Counter

  • Visitors today: 180
  • Visitors yesterday: 535
  • Visitors per day: 59,237
  • Max. visitors per day: 665
  • Total page views: 749,899
  • Page views of this page: 59,237
  • Currently online: 4
  • Max. online: 192
  • Total visitors: 157,597
  • counterStatistics