Commit 5b026e3a authored by Riccardo Padovani's avatar Riccardo Padovani

Double quote vars to prevent globbing and word splitting. Thanks to mapreri

parent 35ad27fc
......@@ -30,22 +30,22 @@ DIR=${1}
DBNAME=${2}
# Check if the directory exists, if not, create it
if [ ! -d $DIR ]; then
mkdir $DIR
if [ ! -d "$DIR" ]; then
mkdir "$DIR"
fi
# If there is yesterday backup, then delete it
if [ -f $DIR/yesterday.tar.gz ]; then
rm -f $DIR/yesterday.tar.gz
if [ -f "$DIR"/yesterday.tar.gz ]; then
rm -f "$DIR"/yesterday.tar.gz
fi
# If there is a backup of today, move it to yesterday
if [ -f $DIR/today.tar.gz ]; then
mv $DIR/today.tar.gz $DIR/yesterday.tar.gz
if [ -f "$DIR"/today.tar.gz ]; then
mv "$DIR"/today.tar.gz "$DIR"/yesterday.tar.gz
fi
# Create the backup
pg_dump $DBNAME > $DIR/today.sql
tar -xczf $DIR/today.tar.gz $DIR/today.sql
pg_dump "$DBNAME" > "$DIR"/today.sql
tar -xczf "$DIR"/today.tar.gz "$DIR"/today.sql
# Remove the temp file
rm $DIR/today.sql
rm "$DIR"/today.sql
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment