Affine final version

This commit is contained in:
2025-05-04 21:06:49 +02:00
parent 43705e2799
commit 452fe2a27c
4 changed files with 17 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ BACKUP_NAME="backup_$DATE.tar.gz"
systemctl --user stop $SERVICE_SERVER systemctl --user stop $SERVICE_SERVER
podman exec $CONTAINER_POSTGRES pg_dump -U $DB_USERNAME -F c -d $DB_DATABASE > $STAGING_DIR/db.dump 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" cp -r "$CONFIG" "$STAGING_DIR/config"
tar -czf "$LOCAL_BACKUP/$BACKUP_NAME" -C "$STAGING_DIR" . tar -czf "$LOCAL_BACKUP/$BACKUP_NAME" -C "$STAGING_DIR" .

View File

@@ -23,16 +23,19 @@ containers=(
) )
for container in "${containers[@]}"; do for container in "${containers[@]}"; do
if podman container exists "$containers"; then if podman container exists "$container"; then
echo "Stop and delete existing container $containers" echo "Stop and delete existing container $container"
if podman inspect -f '{{.State.Running}}' "$containers" | grep -q true; then if podman inspect -f '{{.State.Running}}' "$container" | grep -q true; then
podman stop "$containers" podman stop "$container"
fi fi
podman rm "$containers" podman rm "$container"
fi fi
done done
mkdir -p ./systemd-units mkdir -p ./systemd-units
mkdir -p $DB_DATA_LOCATION
mkdir -p $UPLOAD_LOCATION
mkdir -p $CONFIG_LOCATION
podman create \ podman create \
--name $CONTAINER_REDIS \ --name $CONTAINER_REDIS \
--network $NETWORK \ --network $NETWORK \

View File

@@ -3,7 +3,7 @@ AFFINE_REVISION=stable
NETWORK="affine_net" NETWORK="affine_net"
DOMAIN="" DOMAIN="notedev.jamesvillage.dev"
# set the port for the server container it will expose the server on # set the port for the server container it will expose the server on
AFFINE_PORT=3010 AFFINE_PORT=3010
@@ -15,6 +15,7 @@ AFFINE_PORT=3010
# AFFINE_SERVER_EXTERNAL_URL=https://affine.yourdomain.com # AFFINE_SERVER_EXTERNAL_URL=https://affine.yourdomain.com
# position of the database data to persist # position of the database data to persist
AFFINE_ROOT="$HOME/.affine"
DB_DATA_LOCATION=$HOME/.affine/self-host/postgres/pgdata DB_DATA_LOCATION=$HOME/.affine/self-host/postgres/pgdata
# position of the upload data(images, files, etc.) to persist # position of the upload data(images, files, etc.) to persist
UPLOAD_LOCATION=$HOME/.affine/self-host/storage UPLOAD_LOCATION=$HOME/.affine/self-host/storage
@@ -49,4 +50,6 @@ USER_SYSTEMD="$HOME/.config/systemd/user"
SSL_PATH=$HOME/.config/ssl/$DOMAIN SSL_PATH=$HOME/.config/ssl/$DOMAIN
HAPROXY_CFG_DIR="/etc/haproxy" HAPROXY_CFG_DIR="/etc/haproxy"
HAPROXY_CFG="$HAPROXY_CFG_DIR/haproxy.cfg" HAPROXY_CFG="$HAPROXY_CFG_DIR/haproxy.cfg"
SERVICE_DIR="$HAPROXY_CFG_DIR/services/$DOMAIN" SERVICE_DIR="$HAPROXY_CFG_DIR/services/$DOMAIN"
BACKUP_REMOTE="onedrive-tianyu:Backups/affine"

3
affine/restore.sh Normal file
View File

@@ -0,0 +1,3 @@
# restore example:
cat your_db.dump | podman exec -i your_pg_container pg_restore -U affine -d affine --clean