Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do I go about making a backup image (of just the used space, not the whole drive) of my Ubuntu 8.10 box and having it do this weekly?
Well, there are several ways. You could use a bare-metal recovery tool, like mkcdrec, systemimager, or mondoarchive, which will create a bootable ISO image, suitable for recovering a system if the hard drive dies.
You could use tar to just grab all the files, and shovel them onto a tape/CD/DVD/whatever, so you can read just one file off if needed, or use network backup tools, to backup to a central server.
No matter which you need, CRON can run the job whenever you tell it to. What kind of backup do you want? To what media? What are your backup goals (just need files? Bare-metal?)??
I'd just use tar with gzip compression (bzip2 is quite slow and cpu intensive for such a big backup, though you can use it if you want a smaller backup, though in that case I'd just use 7z). Be sure to read the tar man page, and look specially at the --exclude option which will allow you to exclude dirs like /tmp, /var/tmp, /proc, /dev, /mnt, /media and /sys.
You could also use dd to get a disk image, kind of like a ghost image. If you choose to do so, first make sure to zero out the empty part of the disk first, so the image can be compressed much more effectively. That can be done with this command:
Code:
dd if=/dev/zero of=/tmp/foo bs=4096
It will eventually abort, once the disk is full. Then you can remove /tmp/foo.
To run whatever script weekly, you can put it in /etc/cron.weekly
yes, my hard drive died and i want a bare-metal backup to simply restore/clone the most recent image to disk. i'd like to store the backup images on an external drive. is this actually possible?
yes, my hard drive died and i want a bare-metal backup to simply restore/clone the most recent image to disk. i'd like to store the backup images on an external drive. is this actually possible?
Of course. Cron scripts are run as root, so the same script can be used to mount the drive somewhere, copy the files to the correct place and then unmount the drive again.
If you use "df" you can calculate the amount of free space and use that to calculate the size of a zeroed file. Then delete the file. Now if you use dd to create an image, it will compress better.
Make sure that the external drive uses a filesystem that can hold large files. If you use ieee1394 or even better eSATA, it will be a lot faster.
If you don't compress the image, one trick you could use is to mount the partitions on the image and sync files to it. This will give you the convenience of a fast bare metal restore, in the case of an emergency, while keeping the image up to date.
Look at the info manual for tar. You can use it to easily transport files to a mounted partition:
tar -C / -g timestamp -cf - /usr /home /var | tar -C /mnt/backupdir -xvf - >logfile
This will perform incremental backups, extracting the files to the destination.
The /mnt/backupdir could be the mounted image itself. The first time you run it, it will backup all files. The next time, only new files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.