Restore darjalena.antville.org #409

Closed
opened 2024-03-24 10:18:03 +00:00 by p3k · 1 comment
p3k commented 2024-03-24 10:18:03 +00:00 (Migrated from github.com)

The blog was deleted by accident, see https://help.antville.org/stories/2315813/.

All commands should be executed from within the Host’s shell – except where noted differently.

Retrieve Static Files From Backup

This restores the static files served by Apache (LXC 3000) from /var/www/antville.org/static/sites/darjalena.

$ backup extract -d <number-of-days-ago> share/www/antville.org/static/sites/darjalena

Retrieve Database From Backup

This creates an SQL dump antville.sql with the complete Antville database.

$ backup extract -d <number-of-days-ago> mnt/nvme/dump/antville.sql.bz2
$ tar -jz -f mnt/nvme/dump/antville.sql.bz2
$ mv antville.sql /mnt/common/restoration

Create Temporary Database

…something along the lines of:

$ database -c create database antville-temp
$ database antville-temp < /mnt/common/restoration/antville.sql

Run Export Script

This creates the file darjalena.antville.org.sql with the missing records as SQL dump.

💡 Run this with the temporary database!

#!/usr/bin/env sh

site_name=darjalena

site_id=$(mysql -Nrs antville -e "select id from site where name = '$site_name'")
mysqldump='mysqldump antville -nt --single-transaction' # --extended-insert=false'

$mysqldump choice --where="poll_id in (select id from poll where site_id = $site_id)"
$mysqldump content --where="site_id = $site_id"
$mysqldump file --where="site_id = $site_id"
$mysqldump image --where="parent_type = 'Site' and  parent_id = $site_id"
$mysqldump image --where="parent_type = 'Layout' and parent_id in (select id from layout where site_id = $site_id)"
$mysqldump layout --where="site_id = $site_id"
$mysqldump log --where="context_type = 'Site' and context_id = $site_id"
$mysqldump membership --where="site_id = $site_id"
$mysqldump metadata --where="parent_type = 'File' and parent_id in (select id from file where site_id = $site_id)"
$mysqldump metadata --where="parent_type = 'Image' and parent_id in (select id from image where parent_type = 'Site' and parent_id = $site_id)"
$mysqldump metadata --where="parent_type = 'Image' and parent_id in (select id from image where parent_type = 'Layout' and parent_id in (select id from layout where site_id = $site_id))"
$mysqldump metadata --where="parent_type = 'Layout' and parent_id in (select id from layout where site_id = $site_id)"
$mysqldump metadata --where="parent_type = 'Site' and parent_id = $site_id"
$mysqldump metadata --where="parent_type = 'Story' and parent_id in (select id from content where site_id = $site_id)"
$mysqldump poll --where="site_id = $site_id"
$mysqldump skin --where="layout_id in (select id from layout where site_id = $site_id)"
$mysqldump site --where="id = $site_id"
$mysqldump tag --where="site_id = $site_id"
$mysqldump tag_hub --where="tag_id in (select id from tag where site_id = $site_id)"
$mysqldump vote --where="polL_id in (select id from poll where site_id = $site_id)"

Restore Database Records

💡 Run this with the production database!

$ database antville < /mnt/common/darjalena.antville.org.sql
The blog was deleted by accident, see <https://help.antville.org/stories/2315813/>. All commands should be executed from within the Host’s shell – except where noted differently. ## Retrieve Static Files From Backup This restores the static files served by Apache (LXC 3000) from `/var/www/antville.org/static/sites/darjalena`. ```shell $ backup extract -d <number-of-days-ago> share/www/antville.org/static/sites/darjalena ``` ## Retrieve Database From Backup This creates an SQL dump `antville.sql` with the complete Antville database. ```shell $ backup extract -d <number-of-days-ago> mnt/nvme/dump/antville.sql.bz2 $ tar -jz -f mnt/nvme/dump/antville.sql.bz2 $ mv antville.sql /mnt/common/restoration ``` ## Create Temporary Database …something along the lines of: ```shell $ database -c create database antville-temp $ database antville-temp < /mnt/common/restoration/antville.sql ``` ## Run Export Script This creates the file `darjalena.antville.org.sql` with the missing records as SQL dump. > :bulb: Run this with the *temporary database*! ```shell #!/usr/bin/env sh site_name=darjalena site_id=$(mysql -Nrs antville -e "select id from site where name = '$site_name'") mysqldump='mysqldump antville -nt --single-transaction' # --extended-insert=false' $mysqldump choice --where="poll_id in (select id from poll where site_id = $site_id)" $mysqldump content --where="site_id = $site_id" $mysqldump file --where="site_id = $site_id" $mysqldump image --where="parent_type = 'Site' and parent_id = $site_id" $mysqldump image --where="parent_type = 'Layout' and parent_id in (select id from layout where site_id = $site_id)" $mysqldump layout --where="site_id = $site_id" $mysqldump log --where="context_type = 'Site' and context_id = $site_id" $mysqldump membership --where="site_id = $site_id" $mysqldump metadata --where="parent_type = 'File' and parent_id in (select id from file where site_id = $site_id)" $mysqldump metadata --where="parent_type = 'Image' and parent_id in (select id from image where parent_type = 'Site' and parent_id = $site_id)" $mysqldump metadata --where="parent_type = 'Image' and parent_id in (select id from image where parent_type = 'Layout' and parent_id in (select id from layout where site_id = $site_id))" $mysqldump metadata --where="parent_type = 'Layout' and parent_id in (select id from layout where site_id = $site_id)" $mysqldump metadata --where="parent_type = 'Site' and parent_id = $site_id" $mysqldump metadata --where="parent_type = 'Story' and parent_id in (select id from content where site_id = $site_id)" $mysqldump poll --where="site_id = $site_id" $mysqldump skin --where="layout_id in (select id from layout where site_id = $site_id)" $mysqldump site --where="id = $site_id" $mysqldump tag --where="site_id = $site_id" $mysqldump tag_hub --where="tag_id in (select id from tag where site_id = $site_id)" $mysqldump vote --where="polL_id in (select id from poll where site_id = $site_id)" ``` ## Restore Database Records > :bulb: Run this with the *production database*! ```shell $ database antville < /mnt/common/darjalena.antville.org.sql ```
p3k commented 2024-03-24 10:18:39 +00:00 (Migrated from github.com)

Script ran successfully on Antville.org, see https://darjalena.antville.org/ – closing.

Script ran successfully on Antville.org, see <https://darjalena.antville.org/> – closing.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: antville/antville#409
No description provided.