Backup strategies

Thanks @cim and @mram for sharing and for the food for thought.

I will soon be experimenting with rsnapshot as well to reduce the amount of disk space used by the backups. It doesn’t create a nice archive file for easy download but it at least makes great use of symlinks.

I have tried this script with several time manually it works like charm. Thanks for that.
But the problem is when I am running this on crontab it gives me these errors.
/bin/sh: 1: ee: not found

But when I tried to add PATH vars I get
Error: EasyEngine requires docker-compose.

Is there anyway to fix this guys?

You have to log in as root or sudo -I and set your cron as root.

Oh wait, you have to use bash /script/path/name not sh or ./

ee not found? Either your install is glitched or not properly configured. The ee command requires root or sudo privileges.

I have already tried that one What I get for log is only this message
the input device is not a TTY
and obviously that sql file remove faiiled message…

I am running as root

Seems like this was an issue with v4 Import sql dB v4

ee="/opt/easyengine/sites"
backup="/mnt/backup"
sites=$(ls $ee)
year=`date +%Y`
month=`date +%m`
day=`date +%d`
date=`date +%Y-%m-%d`

mkdir -p $backup/$year/$month/$day

for i in $sites
do
        #ee shell $i --command="wp db export $i.sql"
        db_user=`ee site info $i | grep 'DB User' | awk -F '|' '{print $3}' | awk '{print $1}'`
		db_password=`ee site info $i | grep 'DB Password' | awk -F '|' '{print $3}' | awk '{print $1}'`
		db_host=`ee site info $i | grep 'DB Host' | awk -F '|' '{print $3}' | awk '{print $1}'`
		db_name=`ee site info $i | grep 'DB Name' | awk -F '|' '{print $3}' | awk '{print $1}'`
        docker exec ee-global-db bash -c "mysqldump --no-create-db --opt --add-drop-table -Q -h $db_host -u $db_user -p$db_password $db_name" > $ee/$i/app/htdocs/$i.sql
        cd $ee/$i/app && tar cfJ - htdocs | (pv -ptrb > $i.tar.xz)
        rm $ee/$i/app/htdocs/$i.sql
        mv $ee/$i/app/$i.tar.xz $backup/$year/$month/$day
done

chown -R root:root $backup

Works like a charm… Thanks @cim. Your a life save…
I am really looking forward to see the rsnapshot :smile: It would save a lot of space in the long run.

1 Like

Thanks @cim for the script. I’ve changed the compression from xz to gz since it was painfully slow. xz was ~2mb/s vs gz ~16mb/s. I’ll accept the file size penalty.

I am also doing some tests with escaping the mysql password since I’ve had issues on one of my sites.

1 Like

@cim I used your script for backing up the sites, do you mind sharing the script for restore as well ? thanks

I have long deleted and moved on from EEv4 but I rewrote the script from memory, use this script on a dummy site and also use at your own risk :wink:

#!/bin/bash
#
# $1 = domain.tld
# $2 = 2000/01/01 (Y/m/d format)
#
# bash restore domain.tld 2019/02/22
#

ee="/opt/easyengine/sites"
backup="/home/cim/backup/$2"

cd $backup && tar -xzf $1.tar.gz
sudo rm -rf $ee/$1/app/htdocs
sudo mv $backup/htdocs $ee/$1/app
# when you export a db from wp cli, it'll drop the existing table if it exists
sudo ee shell $1 --command="wp db import $1.sql"
sudo rm $ee/$1/app/htdocs/$1.sql
chown -R www-data:www-data $ee/$1/app/htdocs
1 Like

And where did you go?

Making my own docker stack using traefik, mariadb, and wordpress images. Traefik just makes life easier if I wanna connect other images, which I do, like Rocket.Chat, Gitea, thelounge.chat, etc.

1 Like

So you want to orchestrate your infastructure, in a docker than a server level, with custom open source diployments in far less price than big names do. It looks superb as a idea though, i wish it could implement ee.v4
In my mind it looks hard to build a full custom automation for back end. And front end, customer view?

1 Like

It’s not hard as you think once you get the idea of how each component works. The head banging on the desk comes when you try to put them together lol.

:slight_smile:

I’ve also found it difficult to plan on to add additional services onto EEV4. For example, I really want to run rocketchat, nextcloud, bitwarden etc behind the nginx-proxy container that handles ssl. Can anybody explain the basics of where I’m going to start a new container that connects to the one Easyengine already uses?

Also, I run portainer on the machine now, but can’t get it to terminate https behind the nginx-proxy that already is installed. I find it helpful to give me a view of what’s going on under the hood.

You first have to create the site and let it generate the ssl or skip the nginx conf and ssl if you have wildcard subdomain ssl enabled.

ee site create domain.tld --type=html --ssl=le

Then edit the new domain.tld’s nginx conf, I don’t remember exactly where it was now but I think It was somewhere in /opt/easyengine/services/nginx? Just dig around. Then reload the site:

ee site reload domain.tld --nginx

This might be an issue because jwilder’s nginx-proxy, which EEv4 uses, dynamically overwrites the main .conf for all of your sites. Well just play around with it.

With Traefik, it’s more easier to proxy things and don’t have to edit a file that will maybe get overwritten. Just 5 lines in the .yml file and Traefik will detect it.

labels:
      - "traefik.frontend.rule=Host:domain.tld"
      - "traefik.port=80"
networks:
      - proxy
1 Like

So I would use EEV4 to generate the SSL certs on the nginx-proxy, and then edit the nginx container that does the http config for the site only and point it to the container running nextcloud or rocketchat?
Then hope and pray it doesn’t get overwritten right?

Yep. The custom nginx .conf for each container does not override ports.

HI, @cim, how to export sql databases with htdocs specific upload directly files only.

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