shrinking backup files

Filipe Bonjour fbonjour at urbanet.ch
Tue Oct 4 22:01:42 UTC 2005


Charles,

>Hi all, I recently did a tar cpf etc.tar /etc and tar cpf
>home.tar /home/usrname to make backups.  The .tar file I got for /home
>is huge, 8Gb, is there any way that I can shrink this so that I can burn
>it to a CD?  I dont have a DVD burner, so I would like to use these
>files to burn to CD to back up(unless there is an easier way or
>something I am not aware of)  Thanks, 
>
OK, 8 GB is a lot. Would I be right to assume that most of that space is
taken up with files such as images, songs or movies? These will
practically not compress (because compression is built in in the binary
format, JPEG for images, MP3 for songs of MP4/MPEG/etc for movies).
You'll end up wasting hours of CPU time (yes, gzip'ing, and even more
bzip2'ing is very CPU intensive) for a ridiculous gain.

I would put those images, songs and movies in a separate directory
(outside of /home), and back this up separately, without compression,
directly into an ISO image. Then, use the command "tar cjf
/tmp/home.tar.bz2 /home" to compress the really compressible stuff (text
files and the like). [Or, write a script similar to the one I attach,
see below.]

Incidently, /etc can clearly be compresses, since it's mostly text files.

---

Going a little further, I wrote a small script to backup users data.
(Attached. Use/adapt if you want, but read it first, and of course you
use it at your own risk.) It's the first time I send an attachment to
the list, so if it doesn't get to you, let me know.

Here is how it works:

1) Put a file called .backup in the home directory of the user whose
data you want to backup. This file lists the subdirectories of the home
dir to be backed up. --- This is the way I found to backup only certain
directories in my home directory (tipically, NOT MP3 songs.)

2) Run, as root, backupusr <username>.

Notes:

1. Ignore comments about CD writers. I tried to have the script burn the
CD automatically, but changed my mind and forgot to delete the comments.
Typical.

2. The script calls a separate script to clean Mozilla's/Firefox's cache
in line 76. (Why waste space and time backing up the cache?) Obviously,
you will need to remove that since I don't attach the second script.

3. The compressed backup file is in
/tmp/packages/backup_<username>.tar.bz2. The directory is created if it
doesn't exist.

4. My home dir is around 400 MB, and it takes around 15 minutes to
compress this. If you need something faster, you can change the bz2
compression by a gzip compression by changing the line "bzip2
${TARFILE}" to "gzip ${TARFILE}".

Let me know if it destroys all your data: I'll stop using it myself... :)

Seriously, I hope this ranting helps.

Fil

-- 
Filipe Bonjour

      In theory there is no difference between theory and practice.
      In practice there is. -- Yogi Berra

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: backupusr
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20051005/9ee7af0b/attachment.ksh>


More information about the ubuntu-users mailing list