From 452fe2a27cbbde1c6a660fe9cfbf30e8a473788f Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Sun, 4 May 2025 21:06:49 +0200 Subject: [PATCH] Affine final version --- affine/backup.sh | 2 +- affine/deploy.sh | 13 ++++++++----- affine/env.sh | 7 +++++-- affine/restore.sh | 3 +++ 4 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 affine/restore.sh diff --git a/affine/backup.sh b/affine/backup.sh index 1203661..33ab66f 100755 --- a/affine/backup.sh +++ b/affine/backup.sh @@ -21,7 +21,7 @@ BACKUP_NAME="backup_$DATE.tar.gz" systemctl --user stop $SERVICE_SERVER podman exec $CONTAINER_POSTGRES pg_dump -U $DB_USERNAME -F c -d $DB_DATABASE > $STAGING_DIR/db.dump -cp -r "$UPLOAD" "$STAGING_DIR/upload" +cp -r "$UPLOAD" "$STAGING_DIR/storage" cp -r "$CONFIG" "$STAGING_DIR/config" tar -czf "$LOCAL_BACKUP/$BACKUP_NAME" -C "$STAGING_DIR" . diff --git a/affine/deploy.sh b/affine/deploy.sh index 9acd795..29b2589 100755 --- a/affine/deploy.sh +++ b/affine/deploy.sh @@ -23,16 +23,19 @@ containers=( ) for container in "${containers[@]}"; do - if podman container exists "$containers"; then - echo "Stop and delete existing container $containers" - if podman inspect -f '{{.State.Running}}' "$containers" | grep -q true; then - podman stop "$containers" + if podman container exists "$container"; then + echo "Stop and delete existing container $container" + if podman inspect -f '{{.State.Running}}' "$container" | grep -q true; then + podman stop "$container" fi - podman rm "$containers" + podman rm "$container" fi done mkdir -p ./systemd-units +mkdir -p $DB_DATA_LOCATION +mkdir -p $UPLOAD_LOCATION +mkdir -p $CONFIG_LOCATION podman create \ --name $CONTAINER_REDIS \ --network $NETWORK \ diff --git a/affine/env.sh b/affine/env.sh index c7b98e2..1c281bd 100644 --- a/affine/env.sh +++ b/affine/env.sh @@ -3,7 +3,7 @@ AFFINE_REVISION=stable NETWORK="affine_net" -DOMAIN="" +DOMAIN="notedev.jamesvillage.dev" # set the port for the server container it will expose the server on AFFINE_PORT=3010 @@ -15,6 +15,7 @@ AFFINE_PORT=3010 # AFFINE_SERVER_EXTERNAL_URL=https://affine.yourdomain.com # position of the database data to persist +AFFINE_ROOT="$HOME/.affine" DB_DATA_LOCATION=$HOME/.affine/self-host/postgres/pgdata # position of the upload data(images, files, etc.) to persist UPLOAD_LOCATION=$HOME/.affine/self-host/storage @@ -49,4 +50,6 @@ USER_SYSTEMD="$HOME/.config/systemd/user" SSL_PATH=$HOME/.config/ssl/$DOMAIN HAPROXY_CFG_DIR="/etc/haproxy" HAPROXY_CFG="$HAPROXY_CFG_DIR/haproxy.cfg" -SERVICE_DIR="$HAPROXY_CFG_DIR/services/$DOMAIN" \ No newline at end of file +SERVICE_DIR="$HAPROXY_CFG_DIR/services/$DOMAIN" + +BACKUP_REMOTE="onedrive-tianyu:Backups/affine" \ No newline at end of file diff --git a/affine/restore.sh b/affine/restore.sh new file mode 100644 index 0000000..846d7e9 --- /dev/null +++ b/affine/restore.sh @@ -0,0 +1,3 @@ +# restore example: + +cat your_db.dump | podman exec -i your_pg_container pg_restore -U affine -d affine --clean \ No newline at end of file