Hello guys
thanks for this helpful forum.
I'm new to scripting and doing a little script that dump a sql database with some extra files from a VM of the company I'm in, and create a tar archive to be saved on our serve.
How can I have the tarball to be created with the files generated in the same script?
I keep getting: "cannot extract file, archive empty"
I've tried a wait 10 but that doesn't help.
#!/bin/bash
#
#VARIABLES
#working directory
wd=/opt/fs_db_backup/
if [ ! -d $wd ] ; then
mkdir $wd
fi
runDate=`date +%d_%m_%y-%H%M%S`
vers=$(/home/leo/bin/leostatus | grep vers | awk '{print $5}' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g")
#DUMPING THE DATABASE
/usr/local/pgsql/bin/pg_dump -U leo -f $wd/sql
#CREATES FILE NEEDED FOR RESTORATION
touch $wd/version
touch $wd/md5
#populate and change permissions
echo -n $vers >> $wd/version
#respect the order
cd $wd
md5sum sql >> md5
md5sum version >> md5
chmod -R 640 $wd
#getting everything ready for archive
#mv /opt/fs_db_backup/* /opt/fs_db_backup/tar
#create tar file for backup with absolue path
tar -czvf leo_db_backup-"$runDate".tgz /opt/fs_db_backup/*
#chmod -R 660 leo_db_backup-*
#rsync to server
#rsync -ravptx $tarpath/leo* root@server01/
#weekly retention?
Thank you!