adds resticprofile backup service to compose.yml
34
Dockerfile
@@ -1,34 +0,0 @@
|
||||
FROM docker.io/bitnami/php-fpm:8.4
|
||||
|
||||
WORKDIR /app
|
||||
RUN set -eux \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
acl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY ./symfony/composer.* ./symfony/symfony.* ./
|
||||
COPY ./symfony/.env.prod ./.env
|
||||
RUN composer install \
|
||||
--no-cache \
|
||||
--no-dev \
|
||||
--no-progress \
|
||||
--no-scripts \
|
||||
--optimize-autoloader \
|
||||
--prefer-dist
|
||||
|
||||
WORKDIR /
|
||||
COPY ./scripts ./scripts
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./symfony .
|
||||
|
||||
RUN mkdir -p var/log var/cache && \
|
||||
chown -R www-data:www-data var && \
|
||||
chmod -R 775 var
|
||||
RUN composer install \
|
||||
--no-cache \
|
||||
--no-dev \
|
||||
--no-progress \
|
||||
--optimize-autoloader \
|
||||
--prefer-dist
|
||||
RUN php bin/console doctrine:migrations:migrate latest
|
||||
@@ -4,7 +4,7 @@ networks:
|
||||
|
||||
services:
|
||||
phpfpm:
|
||||
build: .
|
||||
build: ./symfony
|
||||
volumes:
|
||||
- ./php-fpm:/opt/bitnami/php/etc/php-fpm.d
|
||||
expose:
|
||||
@@ -24,3 +24,10 @@ services:
|
||||
volumes:
|
||||
- ./nginx:/opt/bitnami/nginx/conf/server_blocks
|
||||
- ./symfony:/app
|
||||
|
||||
resticprofile:
|
||||
build: ./resticprofile
|
||||
depends_on:
|
||||
- phpfpm
|
||||
volumes:
|
||||
- ./symfony/var:/app/var
|
||||
|
||||
2
resticprofile/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
password.txt
|
||||
16
resticprofile/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
FROM docker.io/creativeprojects/resticprofile:latest
|
||||
ENV TZ=UTC
|
||||
|
||||
RUN set -eux && \
|
||||
apk update && \
|
||||
apk add sqlite && \
|
||||
mkdir -p /app/var/backups
|
||||
|
||||
WORKDIR /etc/resticprofile
|
||||
|
||||
COPY . .
|
||||
RUN chmod +x db_dump.sh entrypoint.sh && \
|
||||
resticprofile schedule --all
|
||||
|
||||
ENTRYPOINT ["/etc/resticprofile/entrypoint.sh"]
|
||||
CMD ["crond", "-f", "-l", "2"]
|
||||
15
resticprofile/db_dump.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
sql_dump_script = ".output
|
||||
.dump
|
||||
.exit"
|
||||
|
||||
cd /app/var
|
||||
for db in *.db
|
||||
do
|
||||
basename=$(echo "$db" | sed "s/\.db$//" | sed "s/\s/_/g")
|
||||
timestamp=$(date +%Y-%m-%dT%H-%M-%S.%N)
|
||||
echo "$sql_dump_script" \
|
||||
| sqlite3 "$db" \
|
||||
> "backups/${basename}_dump_${timestamp}.sql"
|
||||
done
|
||||
6
resticprofile/entrypoint.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
env >> /etc/environment
|
||||
|
||||
echo "$@"
|
||||
exec "$@"
|
||||
46
resticprofile/profiles.toml
Normal file
@@ -0,0 +1,46 @@
|
||||
#:schema https://creativeprojects.github.io/resticprofile/jsonschema/config-1.json
|
||||
version = "1"
|
||||
|
||||
[global]
|
||||
initialize = true
|
||||
log = "/var/log/resticprofile.log"
|
||||
scheduler = "crond"
|
||||
|
||||
[default]
|
||||
description = "Back up database to BackBlazeB2 S3 Bucket"
|
||||
env-file = ".env"
|
||||
password-file = "password.txt"
|
||||
repository = "s3:s3.eu-central-003.backblazeb2.com/joeac-net-backup/repo"
|
||||
verbose = 2
|
||||
|
||||
[default.backup]
|
||||
check-after = true
|
||||
check-before = true
|
||||
run-before = ". /scripts/db_dump.sh"
|
||||
schedule = "*-*-* 03:30:00"
|
||||
schedule-after-network-online = true
|
||||
schedule-lock-wait = "2h"
|
||||
schedule-log = "/var/log/resticprofile-schedule-backup.log"
|
||||
schedule-permission = "system"
|
||||
schedule-priority = "background"
|
||||
source = [
|
||||
"/app/var/backups",
|
||||
]
|
||||
|
||||
[default.forget]
|
||||
keep-last = 2
|
||||
keep-monthly = 2
|
||||
schedule = "*-*-* 03:45:00"
|
||||
schedule-after-network-online = true
|
||||
schedule-lock-wait = "2h"
|
||||
schedule-log = "/var/log/resticprofile-schedule-forget.log"
|
||||
schedule-permission = "system"
|
||||
schedule-priority = "background"
|
||||
|
||||
[default.prune]
|
||||
schedule = "*-*-* 04:00:00"
|
||||
schedule-after-network-online = true
|
||||
schedule-lock-wait = "2h"
|
||||
schedule-log = "/var/log/resticprofile-schedule-prune.log"
|
||||
schedule-permission = "system"
|
||||
schedule-priority = "background"
|
||||
38
symfony/Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
||||
FROM docker.io/bitnami/php-fpm:8.4 AS database
|
||||
WORKDIR /app
|
||||
COPY ./composer.* ./symfony.* ./
|
||||
COPY ./bin ./bin
|
||||
COPY ./.env.prod ./.env
|
||||
COPY ./config ./config
|
||||
COPY ./migrations ./migrations
|
||||
COPY ./src ./src
|
||||
RUN mkdir public \
|
||||
&& composer install --no-cache --no-progress \
|
||||
&& php bin/console doctrine:migrations:migrate latest \
|
||||
&& rm -rf composer.* symfony.* bin .env config migrations src vendor
|
||||
|
||||
FROM database AS apt-install
|
||||
RUN set -eux \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
acl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM apt-install AS composer-install
|
||||
COPY --from=database /app/var /app/var
|
||||
WORKDIR /app
|
||||
COPY ./composer.* ./symfony.* ./
|
||||
COPY ./.env.prod ./.env
|
||||
RUN composer install \
|
||||
--no-cache \
|
||||
--no-dev \
|
||||
--no-progress \
|
||||
--no-scripts \
|
||||
--optimize-autoloader
|
||||
|
||||
FROM composer-install AS copy-src
|
||||
COPY --from=composer-install /app /app
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN mkdir -p var/log var/cache && \
|
||||
chown -R www-data:www-data var && \
|
||||
chmod -R 775 var
|
||||
@@ -36,7 +36,7 @@ final class Version20250522212300 extends AbstractMigration
|
||||
|
||||
public function up(Schema $schema): void {
|
||||
foreach (self::BLOG_POST_SLUGS as $slug) {
|
||||
$blogPostPath = '../scripts/blog-migrated/' . $slug . '.yaml';
|
||||
$blogPostPath = './migrations/blog-migrated/' . $slug . '.yaml';
|
||||
$blogPost = Yaml::parseFile($blogPostPath);
|
||||
|
||||
$publishedDateTime = DateTime::createFromFormat('U', strval($blogPost['pubDate']));
|
||||
|
||||
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
2
todo.txt
@@ -1,7 +1,5 @@
|
||||
Add a most recent blog post to my home page
|
||||
Add a most recent note to my home page
|
||||
Write a script to take a database dump
|
||||
Write a systemd unit to back up a daily database dump to Backblaze
|
||||
Manage secrets in some better way than uncommitted .env files
|
||||
Start serving the website from a Raspberry Pi
|
||||
Add Next and Prev links to each note page
|
||||
|
||||