Full SQL and File backup of all sites on v4 - How I'm doing it using cron via script

Sorry, I don’t have time to record a video for you.

Post an exact copy of your script here - Taking out any passwords or confidential information.

When you post it, be sure to include it in the Preformatted text tags.

Kept this file in the root directly /root/backup.sh also created a folder in /var/Backups
and after that ran a command
i.e /root/backup.sh and tried ./backup.sh

./Backup.sh: 12: [[: not found
./Backup.sh: 12: [[: not found
./Backup.sh: 12: [[: not found
./Backup.sh: 12: [[: not found
tar: Removing leading /' from member names tar: /var/Backups/*.sql: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors tar: Removing leading /’ from member names
tar: Removing leading `/’ from hard link targets


PASSWORD=`cat /opt/easyengine/services/docker-compose.yml | grep MYSQL_ROOT_PASSWORD | awk -F'=' '{print $2}'`
DATETIME=`TZ=":America/Edmonton" date +%Y%m%d-%H%M`
DOCKERDatabaseID=`docker ps | grep -e 'services_global-db' | cut -c1-12;`
databases=`docker exec $DOCKERDatabaseID bash -c "mysql -h localhost --user=$USER --password=$PASSWORD -e 'show databases;'" | tr -d "| " | grep -v Database`
for db in $databases; do
    if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ;
	#uncomment this next line if you want to know which DB the script is on.
	#echo "Dumping database: $db"
	sudo docker exec $DOCKERDatabaseID bash -c "/usr/bin/mysqldump -u $USER -p$PASSWORD --databases $db" > $OUTPUT/$db.sql
tar -jcf $OUTPUT/DBs-$DATETIME.tar.bz2 $OUTPUT/*.sql
rm -f $OUTPUT/*.sql
tar -jcf $OUTPUT/siteFiles-$DATETIME.tar.bz2 /opt/easyengine/sites/* --dereference

I’m running EE v4.1.3 and it still works for me, but maybe something has changed in v4.1.4 or v4.1.5.

Try these things, one at a time;

  • Double-check that the folder /var/Backups has both a capital B and a trailing ‘s’ (ie, it’s not /var/backups or /var/Backup
  • Change the line OUTPUT="/var/Backups" to OUTPUT="var/Backups"
  • manually run each line up until the line that just says ‘done’. Then go into /var/Backups and let me know what files are there (I’m guessing there may be no .sql files, meaning the SQL backup is failing, and when those files are being compressed the line is failing because there’s nothign to compress.

/var/backups or /var/Backup - /var/Backup only
OUTPUT="/var/Backups" - saving zip files, (not sql)
OUTPUT="var/Backups" - but If remove the slash then not working.

can you please send me the simple commands without any sql compression, just sql dump with root password. ex: “?U\FhhLy5\zt4RL”

run this;

docker ps

and tell me the value in the last column on the row that has “easyengine/mariadb:v4.1.3” in the 2nd column. (the v4.1.3 may be slightly different for you)

How can I find the location of the backup results?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.