Quote:
| Originally Posted by SimonJM How and where do you plan to this archive with and to? What, if any, requirements do you have for it's retrieval? Do you have any specific format for the configuration file and it's location? |
Hi ,
I am sending the contents of the configuration file...and in the folder i want to extract all the XML files and make the tar and then send that tar in the output directory as mentioned in th configuration file....so the name of the configuration file is (backup.sh)..
backup.sh(configuration file)
*************************
#!/bin/bash
# backup files in here
DIRTOBACKUP=/home/Administrator/files
# tarballs get stored here
TARDIR=home/Administrator/output
# File containing patterns to save
PATTERNFILE=/home/Administrator/scripts/patfile.sh
# Kind of timestamp to use in the tar files
TIMESTAMP="%F-%R" # yyyy-mm-dd-hh:mm
and there is anothr script file which will be using the details from the configuration file that is ne1.sh and it contents are....
(ne1.sh)
****************************
#!/bin/bash
#. ./home/admistrator/scripts/configration.sh
# . /home/Administrator/scripts/app.properties
. /home/Administrator/scripts/backup.sh
# echo DIRTOBACKUP
# echo TARDIR
# echo PATTERNFILE
# echo TIMESTAMP
# prints an error message to stderr and quits.
# ' [ something ] || die "message" ' quits with 'message' when something is false.
# ' [ something ] && die "message" ' quits with 'message' when something is true.
function die
{
echo "$0: $@" >&2
exit 1
}
[ -f /home/Administrator/scripts/backup.sh ] || die "No config file" # check for config file
[ -f "$PATTERNFILE" ] || die "No pattern file" # check for pattern file
[ -d "$DIRTOBACKUP" ] || die "No input dir" # check for input dir
[ -d "$TARDIR" ] || die "No archive dir" # check for archive dir
[ -z "$TIMESTAMP" ] && die "No timestamp format" # need a time format
# create a filename from today's date. See man date.
TARFILE="backup_$(date "+${TIMESTAMP}").tar"
# Find all files inside $DIRTOBACKUP.
find "$DIRTOBACKUP" -type f |
# Match things in $PATTERNFILE, excluding the rest.
grep -f "$PATTERNFILE" |
# Feed the filenames into tar via xargs.
xargs -I {} | tar -rcf "${TARDIR}/${TARFILE}
and the last is pattern file where I mentioned the pattern to extract all the xml files...it name is patfile.sh..and it contents are...
patfile.sh
*********
#!/bin/bash
\.xml$
now the problem is upon executing I got the error that no pattern file ...plz giide me upon this or plz tell me some onother approch as I am stuck upon this..
