shrinking backup files

James Gray james at grayonline.id.au
Tue Oct 4 21:05:02 UTC 2005


On Wednesday 05 October 2005 06:34, Charles Malespin wrote:
> > >  tar czvf /path/to/file tar-archive.tar.gz
>
> Tried this:
> sudo tar cjvf /home/malespin/backup/home.tar tar-archive.tar.bz2
>
> and got:
> tar: tar-archive.tar.bz2: Cannot stat: No such file or directory
> tar: Error exit delayed from previous errors
>
> for both of them.

According to "man tar", when you specify the "f" option, the next argumnet 
after that is the ARCHIVE file name, then the second argument will be the 
source files, eg:

tar zcvf myarchive.tar.gz /path/to/source/files

> How do you split up the /etc and /home files to make smaller ones?  I am
> willing to try anything, just need to get these files on a CD to have a
> back up.

What about a simple script?  The one below is to get you started and should 
create two archives in the directory you execute it from called:
home-20051005.tar.gz and etc-20051005.tar.gz.  (the numbers will change each 
day you run the script obviously).

I think the script is pretty self-explanatory, but feel free to ask questions.  
You may want to google the "Bash scripting guide" and read "man tar" first ;)

#!/bin/bash
for DIR in home etc
do
    SRC="/$DIR"
    NOW=$(date +%Y%m%d)
    ARCH="$DIR-$NOW.tar.gz"
    echo "Backing up $SRC to $ARCH"
    tar zcvf $ARCH $SRC
done

This script assumes the directories listed in the "for DIR in..." line are off 
the root directory.  You may want to test with some small directories first 
and verify the archives that are created as the script above is untested 
(just punched it out off the top of my head).

HTH,

James
-- 
Things are not as simple as they seems at first.
- Edward Thorp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20051005/f41a5e44/attachment.pgp>


More information about the ubuntu-users mailing list