tar inside cron

hi,

i would like to backup some file everyweek

0 0 * * 0 tar -cvf abc.tar abc;gzip abc.zip

i would not replace the abc.zip,

thats mean the next week backup will become abc.zip1 ....abczip2........

how?

btw, is the any way beside '0 0 * * 0 tar -cvf abc.tar abc;gzip abc.zip' ?

thanx
bsherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bedotCommented:

0 0 * * 0 tar -cvf abc.tar abc;name=abc.zip;extent=`date +%W`; name=${name}$extent;gzip $name

that create each week a backup zipped with the extent is suffixed with the numero of the week in the year


format options of date:

.....
    U   Week number of the year (Sunday as the first day of the week) as a
        decimal number in the range 00 - 53

    W   Week number of the year (Monday as the first day of the week) as a
        decimal number in the range 00 - 53

    X   Current time, as defined by the locale

    Y   Year (including century), as decimal numbers

    Z   Timezone name, or no characters if no timezone exists

    a   Abbreviated weekday - Sun to Sat

    b   Abbreviated month name

    c   current date and time, as defined by the locale

    d   Day of month - 01 to 31
.....

(see man pages of date)
0
bsherAuthor Commented:
i  tried this way but failed

tar -cvf /home/abc/backup.tar
/home/abc/file/*.txt
/home/abc/file/data/*.txt;
name=backup.tar;extent='date+%W';
name=${name}$extent;
gzip /home/abc/$name

home/abc/file/word.txt
home/abc/file/time.txt
home/abc/file/data/mail.txt
home/abc/file/data/user.txt
/home/abc/backupdate+%W: No such file or directory

i would like to backup the *.txt from 2 different dir

once a week , eg:
1 nov 99 backup.tar.gzip.1

7 nov 99 backup.tar.gzip.2
             backup.tar.gzip.1

14 nov 99  backup.tar.gzip.3
                   backup.tar.gzip.2
                     backup.tar.gzip.1

thanx
bsh
0
qazakaCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
j2Commented:
you are over complicating the problem

tar czvf abc.tgz`date +%V` abc

will create abc.tgzWEEKNUMBEROFYEAR

but tar czvf abc`date +%V`.tgz will prolly look cleaner.

will do the trick. note that the ` is a BACKTICK, it is NOT a ' or a ´
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.