O
O
OlZhi2021-11-23 12:10:37
bash
OlZhi, 2021-11-23 12:10:37

Error in backup script?

#!/bin/bash

FILES_DIR="/var/www"
BACKUP_DIR="/mnt/backup"

TIMESTAMP='data +"%Y-%m-%d_%H-%M-%S"'

mount $BACKUP_DIR

mysqldump -uroot -hlocalhost -pSuper2021 --all-databases > $BACKUP_DIR/$TIMESTAMP.sql
tar -czvf $BACKUP_DIR/$TIMESTAMP.tar.gz $FILES_DIR/

umount $BACKUP_DIR

exit 0;


It is necessary to save the backup as
Date-time.sql
Date-time. tar.gz

is now saved as data

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2021-11-23
@OlZhi

TIMESTAMP='data +"%Y-%m-%d_%H-%M-%S"'
Your quotes are wrong here. Single quotes are just text. Backward single quotes are command substitution (what you meant to do)
But it's better to use the $() construct:
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
ps and yes, you have data instead of date

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question