 | Junior Member with 16 posts. | | | | TAR -N _______ backup Iīm trying to make a shell script to backup files whose path I read from an another file(say "backup.conf").
My script is called "backup" (original, isnīt it?), and the user can write on the command line just "./backup" or "./backup DATE", where date has the format year/month/day. After that I check the backup.conf to get the path of the files(or directories), to see if the date of the file is newer than the date given by the user, if so I backup the file(using tar).
My problem comes here---> To check the date I try to use tar -N=DATE but I keep getting an error.
For example I write tar -zcf -N=20020418 backup.tar.gz file1
I also tryied the following:
tar -zcf -N=2002-04-03 backup.tar.gz file1
tar -zcf -N=2002/04/09 backup.tar.gz file1
And also tryied the following to check, and did not work:
tar -zcf -N="2 days ago" backup.tar.gz file1
tar -zcf --newer 20020411 backup.tar.gz file1
Sometimes I donīt get an error, but tar cerates an empty tar file.
PLEASE, somebody help me! I checked for the syntaxsis all around the web, and all that I found is confusing me more and more... Whatīs wrong with that command? is the date format wrong? Please, somebody give me a hand. | | Senior Member with 1,410 posts. | | | | Wow! -- you have stumbled upon one of the more arcane Unix/Linux commands (albeit a very useful one). You don't mention which version of Unix/Linux you are using, so the following suggestion may not work for you (but then again, it might). Here's what could be happening:
There's nothing wrong with your syntax, per se (and you have the correct date format YMD). You could be experiencing the heritage of the tar command that dates back to BSD Unix days. The tar command expects that when you give it the -f option, that option will immediately be followed by the filename to be operated on -- i.e., NOT more options to the tar command. So instead of (for example):
tar -zcf -N ...
try:
tar -zc -N ... -f backup.tar.gz file1 ...
and see if that makes any difference.
That's one possibility. Another is that you don't need the equal sign in the specification of the date (i.e., -N date instead of -N=date). My Linux distribution doesn't use the equal sign after the -N option, but yours may be different.
Hope this helps.
__________________ The slowest component still sits at the keyboard. | | Junior Member with 16 posts. | | | | Iīm using both (linux) Debian and RedHat(7.2).
Tryied that syntax in both of them and didnīt work. But at least I went one step further: I realyzed I donīt need the equal(=) sign.
Anyway, Iīm still working on it...
Since I couldnīt find the way to backup files with "tar -N" Iīm trying to do it with "find -ctime".
I mean, I have a file with the paths of the directories I wanna backup(backup.conf), one path per line, and Iīm trying to copy into a temp file those PATHS whose "date" is newer than DATE (with format yyyy/mm/dd).
What I do is to calculate the number of days that have passed between DATE and today, and call this number "NUMBER". Then, I check each line of backup.conf with the command
find -ctime NUMBER
In this way I get the PATH those files whose date is newer that DATE, right? Then copy all those paths into temp and finally "tar zip" them (with tar -zc ... -F ...)
Itīs quiet confusing, and Iīm quite sleepy...
Got the idea of what Iīm doing??
THE PROBLEM is that the find -ctime is not working...it isnīt checking the date restriction, and itīs coying all the paths into the temp file, itīs like Iīm putting code for nothing!!!
Any idea of:
- How to check the date restriction with "find"
- How to find the "tar" syntax that works
fine with redhat
- How the hell backup those files with
that date restriction??
Thaks for reading all the way down here, any answer/help is welcome :| | | Senior Member with 1,410 posts. | | | | On my system, the following command creates a tar archive of all files in directory tree /home/blablabla that are newer than 25 march, 2002:
tar -N 20020325 -cvf tar.out /home/blablabla
Try substituting your directory of choice for /home/blablabla. If this doesn't work for you on either of your distributions, could you post the actual error message?
Also, your find command may not be working properly because the -ctime option likely behaves differently than you realize (not that there's any decent discussion of how it behaves on the find man page, no, that would make too much sense!  ). Have a look at the fstat man page, and peruse the sections on st_atime, st_ctime and st_mtime. I suspect mtime may be closer to what you have in mind.
Hope this helps.
__________________ The slowest component still sits at the keyboard. | | Junior Member with 16 posts. | | | | codejockey:::a newbie, sorry!! I'm really new with linux, I started using it for the first time a month ago, or maybe 1 and 1/2. So, sometimes(quite often) I don't understand basic stuffs. Anyway, today I finally backuped my files using tar. Hey...Thanks...
I did what you told me to do, and it worked, but I thought it wasn't working, since all the files that can not be backuped(they don't fit the date restriction) are dislpayed on the .tar file, but just the name, saying "file not dumped". And well, I always wondered what "dumped" meant, and I guess that was MY PROBLEM.
So sorry to bother you for nothing, next time I'll go straight to the dictionary. I guess I have to improve my english and linux skills, right??! :|
blablabla | | Senior Member with 1,410 posts. | | | | Way to go, blablabla! -- glad things worked for you -- and no need to apologize for being new to Linux. As you probably noticed, Linux/Unix has a well-deserved reputation for being user-hostile, not to mention arcane and confusing. Hang in there -- it gets better and things start making more sense after awhile, even though at first it seems overwhelming and nothing like any O/S you've used before.
__________________ The slowest component still sits at the keyboard. |  THIS THREAD HAS EXPIRED.
Are you having the same problem?
We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.
|
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 07:51 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|