marineenergy / server

server software install using Docker
0 stars 0 forks source link

DB backups #4

Closed geocoug closed 2 years ago

geocoug commented 2 years ago

Schedule nightly DB backups pushed to remote (Integral) server.

geocoug commented 2 years ago

May also want to consider archiving with Block Storage Volumes.

bbest commented 2 years ago

Added postgis-backup service here:

https://github.com/marineenergy/server/blob/8c1c7cd4bde68f235d8a72a982b4427c693e8a02/docker-compose.yml#L66-L80

with these commits:

Next steps:

  1. see if backups show up after 11pm scheduled time in host path /share/postgis-backups
  2. attach a new volume independent of host for mounting and updating /share/postgis-backups Screen Shot 2022-05-19 at 1 42 54 PM
bbest commented 2 years ago

Hi @geocoug,

Ok, I ran git pull and docker-compose up -d to get the latest:

bbest@mhk-data-ubuntu:~/mhkenvserversoftware$ git pull
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
From https://github.com/marineenergy/server
   8c1c7cd..c06d378  master     -> origin/master
Updating 8c1c7cd..c06d378
Fast-forward
 docker-compose.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

bbest@mhk-data-ubuntu:~/mhkenvserversoftware$ docker-compose up -d
nginx-dev is up-to-date
nginx is up-to-date
rstudio is up-to-date
postgis is up-to-date
proxy is up-to-date
Recreating postgis-backup ... 
letsencrypt is up-to-date
Recreating postgis-backup ... done

Hopefully we'll see the backup there tomorrow in /mnt/backups:

bbest@mhk-data-ubuntu:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           798M  1.2M  797M   1% /run
/dev/vda1       155G   38G  118G  25% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vda15      105M  8.9M   96M   9% /boot/efi
/dev/sda        496G  226G  246G  48% /share
tmpfs           798M     0  798M   0% /run/user/1000
/dev/sdb        100G   61M   95G   1% /mnt/backups
bbest commented 2 years ago

So @geocoug fixed with:

Ah good eye Caleb. Yes, the database container was not properly referenced so your db to postgis fix should do it. I just updated server:

cd mhkenvserversoftware/
git pull
docker-compose up -d

If it still has trouble producing backups overnight, I'll inspect the server logs with:

docker logs postgis-backup

Thanks a bunch, Ben

bbest commented 2 years ago

Woohoo @geocoug,

The postgis backups are working:

bbest@mhk-data-ubuntu:/mnt/backups/pg_backups$ tree
.
├── 2022
│   └── May
│       ├── PG_gis_gis.20-May-2022.dmp
│       ├── PG_gis_gis.21-May-2022.dmp
│       ├── PG_gis_gis.22-May-2022.dmp
│       └── PG_gis_gis.23-May-2022.dmp
└── globals.sql

2 directories, 5 files

bbest@mhk-data-ubuntu:/mnt/backups/pg_backups$ ls -lh 2022/May/
total 6.8G
-rw-r--r-- 1 root root 1.7G May 20 23:05 PG_gis_gis.20-May-2022.dmp
-rw-r--r-- 1 root root 1.7G May 21 23:04 PG_gis_gis.21-May-2022.dmp
-rw-r--r-- 1 root root 1.7G May 22 23:04 PG_gis_gis.22-May-2022.dmp
-rw-r--r-- 1 root root 1.7G May 23 23:05 PG_gis_gis.23-May-2022.dmp