Answer the question
In order to leave comments, you need to log in
How to backup a directory?
I have a sample code, but this code backs up the database. How to backup a directory and can it be written in one file or in another already?
Database backup code
#!/bin/bash
FILES_DIR="/var/www"
BACKUP_DIR="/mnt/backup"
TIMESTAMP=`date +"%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;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question