LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Getting date format right in tar incremental backup (https://www.linuxquestions.org/questions/linux-software-2/getting-date-format-right-in-tar-incremental-backup-219528/)

jonr 08-18-2004 10:20 PM

Getting date format right in tar incremental backup
 
I'm trying to learn to do both full and incremental tar backups. Here is the full backup script I wrote, after studying some examples here and there:
----------------------------------------------------------
#!/bin/sh

LASTFULL=`date +%F% %T`
echo $LASTFULL > /store_1/tar_bkp/last_full_backup_date

tar -c -v -z -f /store_1/tar_bkp/full_backup.tgz /home/jon/Documents
----------------------------------------------------------

That works just fine. Then I tried an incremental-backup script, here:
----------------------------------------------------------
#!/bin/sh
LASTFULL="`cat /store_1/tar_bkp/last_full_backup_date`"
tar -c --newer $LASTFULL -v -z -f /store_1/tar_bkp/incremented_backup.tgz /home/jon/Documents
echo $LASTFULL
-----------------------------------------------------------
and no matter what date format I try (referring to the GNU tar webpage for acceptable formats, and also trying some that turned out no good), the result is always a full backup
just like the first script produces, within a few bytes. (I'm experimenting with just one large directory to save time, and later I will backup all my files.)

What date format do I need to specify the year, month, day, hour, minute, and second?
And why, when I experiment with a supposedly OK date format, does the result still equal
a full backup?

Many thanks in advance.

320mb 08-19-2004 12:12 AM

http://www.linuxquestions.org/questi...ckup+your+data

jonr 08-19-2004 09:02 AM

Thanks, 320mb. I saved that page for further study.

However, unless I'm missing something in reading it, it doesn't address the incremental backup property that's stumping me. My full backup works fine. But the ones with the incremental switch "N" (I also tried --newer and --after-date with same result) also produce, not incremental (smaller) tar files, but the same full-sized one as without the switch. Even when the date format seems to be OK for tar. I can only guess I'm doing something wrong when I specify the date. But I've re-read the manual and GNU website pages several times and can't see where I'm going wrong.

jonr 08-19-2004 09:53 AM

Quote:

Originally posted by jonr
But I've re-read the manual and GNU website pages several times and can't see where I'm going wrong.
OK, I got the date format to work, and the incremental backup to be just that.

What I needed was a backslash to put a literal space in the date. The manual probably assumes every reader knows that and doesn't mention it. (This kind of assumption is REALLY common...)

So it turns out the date-file creation that works, in the form I wanted it, goes:

LASTFULL=`date +%F\ %T`

Unfortunately (or not), in the process of getting to this point, I also read that it's not recommended to make incremental backups this way! Sometimes certain files are not detected etc.

Back to the drawing board. At least I know how to specify dates for tar now.


All times are GMT -5. The time now is 05:34 PM.