ItinerisLtd / trellis-backup-during-deploy

Backup WordPress database during Trellis deploys

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't find database backup file... Not working?

E-VANCE opened this issue · comments

Hi there,

great plugin / hook for the Trellis deploy! Thanks for sharing.

I followed your instructions and installed like this:

  • Added the role to requirements.yml
  • Added the role to the deploy_initialize_after hook
  • Re-provisioned my servers (local / remote)

Upon running the deploy I see this in the following output (verbose)

    ok: [xxx.xxx.xx.xxx] => {
        "changed": false,
        "cmd": [
            "wp",
            "db",
            "export"
        ],
        "delta": "0:00:00.xxxxx",
        "end": "2018-04-19 12:25:54.546537",
        "invocation": {
            "module_args": {
                "_raw_params": "wp db export",
                "_uses_shell": false,
                "chdir": "/srv/www/example.com/current",
                "creates": null,
                "executable": null,
                "removes": null,
                "stdin": null,
                "warn": true
            }
        },
        "rc": 0,
        "start": "2018-04-19 12:25:54.275770",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "Success: Exported to 'example_com_staging-2018-04-19-a2aa209.sql'.",
        "stdout_lines": [
            "Success: Exported to 'example_com_staging-2018-04-19-a2aa209.sql'."
        ]
    }

but the .sql-file doesn't show up in my current release folder...

web@example:/srv/www/example.com/current$ ll -a
total 100
drwxr-xr-x 5 web www-data  4096 Apr 19 12:26 ./
drwxr-xr-x 8 web www-data  4096 Apr 19 12:26 ../
-rw-r--r-- 1 web www-data  4950 Apr 19 11:11 CHANGELOG.md
-rw-r--r-- 1 web www-data  3188 Apr 19 11:11 CODE_OF_CONDUCT.md
-rw-r--r-- 1 web www-data  6591 Apr 19 11:11 composer.json
-rw-r--r-- 1 web www-data 34407 Apr 19 11:11 composer.lock
drwxr-xr-x 3 web www-data  4096 Apr 19 11:11 config/
-rw-r--r-- 1 web www-data   998 Apr 19 12:26 .env
-rw-r--r-- 1 web www-data   466 Apr 19 11:11 .env.example
-rw-r--r-- 1 web www-data   248 Apr 19 11:11 .gitignore
-rw-r--r-- 1 web www-data  1044 Apr 19 11:11 LICENSE.md
-rw-r--r-- 1 web www-data  3976 Apr 19 11:11 README.md
drwxr-xr-x 8 web www-data  4096 Apr 19 12:26 vendor/
drwxr-xr-x 4 web www-data  4096 Apr 19 12:26 web/
-rw-r--r-- 1 web www-data    13 Apr 19 11:11 wp-cli.yml

How come?

I applied the #975-commit to Trellis but only that one, I skipped updating Trellis completely (the latest one seems to be #968) since I thought that wouldn't be necessary... Could that be the issue? Does it have any other dependencies when it comes to the recent Trellis commits?

Thanks & regards!

Look for the db dump under /srv/www/example.com/releases, not current.

This is because current is a symbolic link and Trellis changes it after our db export task.

Thumb of rule: If you want to rollback to releases/2018111111, then you look for the db dump at /srv/www/example.com/releases/2018111111/*.sql.

I thought as much and already checked /srv/www/example.com/releases – same there:

web@querstadtein:/srv/www/example.com/releases/20180419213041$ ll -a
total 100
drwxr-xr-x 5 web www-data  4096 Apr 19 21:31 ./
drwxr-xr-x 8 web www-data  4096 Apr 19 21:31 ../
-rw-r--r-- 1 web www-data  4950 Apr 19 21:29 CHANGELOG.md
-rw-r--r-- 1 web www-data  3188 Apr 19 21:29 CODE_OF_CONDUCT.md
-rw-r--r-- 1 web www-data  6591 Apr 19 21:29 composer.json
-rw-r--r-- 1 web www-data 34407 Apr 19 21:29 composer.lock
drwxr-xr-x 3 web www-data  4096 Apr 19 21:29 config/
-rw-r--r-- 1 web www-data   998 Apr 19 21:31 .env
-rw-r--r-- 1 web www-data   466 Apr 19 21:29 .env.example
-rw-r--r-- 1 web www-data   248 Apr 19 21:29 .gitignore
-rw-r--r-- 1 web www-data  1044 Apr 19 21:29 LICENSE.md
-rw-r--r-- 1 web www-data  3976 Apr 19 21:29 README.md
drwxr-xr-x 8 web www-data  4096 Apr 19 21:31 vendor/
drwxr-xr-x 4 web www-data  4096 Apr 19 21:31 web/
-rw-r--r-- 1 web www-data    13 Apr 19 21:29 wp-cli.yml

Running wp db export manually in the folder does the trick, the DB file (example_com_staging-2018-04-19-c995812.sql) appears as expected...

Check all directories under releases.

Assume that all deploys are using this role and successful, you can find one .sql file under each release directory expect the latest one.

Indeed... Makes sense to pair the DB export with the actual (= last) release, sorry that I didn't think about that...!

Added #5 for some clarification.