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} ...@@ -30,22 +30,22 @@ DIR=${1}
DBNAME=${2} DBNAME=${2}
# Check if the directory exists, if not, create it # Check if the directory exists, if not, create it
if [ ! -d $DIR ]; then if [ ! -d "$DIR" ]; then
mkdir $DIR mkdir "$DIR"
fi fi
# If there is yesterday backup, then delete it # If there is yesterday backup, then delete it
if [ -f $DIR/yesterday.tar.gz ]; then if [ -f "$DIR"/yesterday.tar.gz ]; then
rm -f $DIR/yesterday.tar.gz rm -f "$DIR"/yesterday.tar.gz
fi fi
# If there is a backup of today, move it to yesterday # If there is a backup of today, move it to yesterday
if [ -f $DIR/today.tar.gz ]; then if [ -f "$DIR"/today.tar.gz ]; then
mv $DIR/today.tar.gz $DIR/yesterday.tar.gz mv "$DIR"/today.tar.gz "$DIR"/yesterday.tar.gz
fi fi
# Create the backup # Create the backup
pg_dump $DBNAME > $DIR/today.sql pg_dump "$DBNAME" > "$DIR"/today.sql
tar -xczf $DIR/today.tar.gz $DIR/today.sql tar -xczf "$DIR"/today.tar.gz "$DIR"/today.sql
# Remove the temp file # 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