• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

RH 7.2 Interesting Problem

Tagge

n00b
Joined
Jul 2, 2002
Messages
56
Hey folks,

I'm doing a backup from one of our RH servers to another. All I want it to do is create a .tar file with the name of said file as the date in an acceptable format (Aug 10, 2004 ; or something of the like). What commands in RH can I use to do this? I've tried passing the date command to a variable, however it just outputs the actual text (IE 'Date= %D' or a similiar output). Any suggestions on howto remedy this and allow me to create a file with the actual date as the name? Help / suggestions are appreciated.

Peace,
-T.
 
So just to understand what you are wanting to do here.

You want to create .tar files but have them automaticly be named a " date " is that correct ?

so something like this ? let me know i'll try to help as much as a i can ** side not this should really be in the Linux/BSD section ** :D

#Change the 5 variables below to fit your computer/backup

COMPUTER=deep # name of this computer
DIRECTORIES="/home" # directoris to backup
BACKUPDIR=/backups # where to store the backups
TIMEDIR=/backups/last-full # where to store time of full backup
TAR=/bin/tar # name and locaction of tar

#You should not have to change anything below here

PATH=/usr/local/bin:/usr/bin:/bin
DOW=`date +%a` # Day of the week e.g. Mon
DOM=`date +%d` # Date of the Month e.g. 27
DM=`date +%d%b` # Date and Month e.g. 27Sep

# On the 1st of the month a permanet full backup is made
# Every Sunday a full backup is made - overwriting last Sundays backup
# The rest of the time an incremental backup is made. Each incremental
# backup overwrites last weeks incremental backup of the same name.
#
# if NEWER = "", then tar backs up all files in the directories
# otherwise it backs up files newer than the NEWER date. NEWER
# gets it date from the file written every Sunday.


# Monthly full backup
if [ $DOM = "01" ]; then
NEWER=""
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DM.tar $DIRECTORIES
fi

# Weekly full backup
if [ $DOW = "Sun" ]; then
NEWER=""
NOW=`date +%d-%b`

# Update full backup date
echo $NOW > $TIMEDIR/$COMPUTER-full-date
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES

# Make incremental backup - overwrite last weeks
else

# Get date of last full backup
NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`"
$TAR $NEWER -cf $BACKUPDIR/$COMPUTER-$DOW.tar $DIRECTORIES
fi

********************************************************************************************************

Here is an abbreviated look of the backup directory after one week: [root@deep] /# ls -l /backups/



total 22217
-rw-r--r-- 1 root root 10731288 Feb 7 11:24 deep-01Feb.tar
-rw-r--r-- 1 root root 6879 Feb 7 11:24 deep-Fri.tar
-rw-r--r-- 1 root root 2831 Feb 7 11:24 deep-Mon.tar
-rw-r--r-- 1 root root 7924 Feb 7 11:25 deep-Sat.tar
-rw-r--r-- 1 root root 11923013 Feb 7 11:24 deep-Sun.tar
-rw-r--r-- 1 root root 5643 Feb 7 11:25 deep-Thu.tar
-rw-r--r-- 1 root root 3152 Feb 7 11:25 deep-Tue.tar
-rw-r--r-- 1 root root 4567 Feb 7 11:25 deep-Wed.tar
drwxr-xr-x 2 root root 1024 Feb 7 11:20 last-full
 
Human,

That's exactly what I've been trying to do (or very very similiar anyway). The issue at hand is that when I use the $Now function to call the date upon creating the file inside RH7.2 it creates two files date.tar and %D.tar (Or for the second one whatever formatting techique I'm using). Basically what happens is the command reads the exact text in the variable rather than what the variable will equal if the command is run.

The amusing thing is we're doing the exact same command in RH6.0 for one of our older servers and it works perfectly. However, RH7.2 produces the aforementioned result. I'm thinking this has to be some sort of bug in RH 7.2? I'm not sure. Any other ideas?

Peace,
-T.
 
Back
Top