Code in this video_Script Automatic Backup WordPress Website with Crontab Schedule
# Replace the highlighted part with your information
#!/bin/bash
# Source directory to be backed up
SOURCE_DIR="path_of_the_WordPress_directory"
# Destination directory
DEST_DIR="path_of_the_destination_directory"
# MySQL information
MYSQL_USER="database_user"
MYSQL_PASSWORD="database_password"
DATABASE_NAME="database_name"
# Get the current date
DATE=$(date +"%Y%m%d")
# Create a compressed file name based on the date
ZIP_FILE="$DATE.zip"
# Backup the directory to the destination directory
cp -r "$SOURCE_DIR" "$DEST_DIR"
# Backup MySQL database and name it following the same format as the directory
mysqldump --user="$MYSQL_USER" --password="$MYSQL_PASSWORD" "$DATABASE_NAME" > "$DATE.sql"
# Compress the directory and SQL file into a zip file
zip -rq "$ZIP_FILE" "mysite" "$DATE.sql"
# Delete the directory and SQL file after compressing into the zip file
rm -rf "mysite" "$DATE.sql"
#### Daily automatic backup scheduled for 23:00
0 23 * * * cd path_of_script_backup_directory && name_of_script.sh
# Example: 0 23 * * * cd /backup && backup.sh