feat: enabled multi-domain setup

This commit is contained in:
2025-08-25 15:26:11 -07:00
parent 4eab6b38b2
commit bb1ea6e778
6 changed files with 19 additions and 17 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
staging/bitwarden/

View File

@@ -1,3 +1,3 @@
ROOT_DIR=/opt/bitwardenrs
ETC_DIR=/etc/bitwardenrs
S3_BUCKET=bitwarden.exceede.com
DATABASE_URL=bitwarden

View File

@@ -22,7 +22,7 @@ function check_for_hash() {
function create_and_upload() {
local sum=$1
local backup_file
backup_file="$(date +%Y/%m/backup-%d-%H-%M-%S.tar.gz)"
backup_file="$(date +%Y/%m/${DATABASE_URL}_backup-%d-%H-%M-%S.tar.gz)"
echo "Uploading ${backup_file}"
tar -zc . | aws s3 cp - "s3://${S3_BUCKET}/${backup_file}"
aws s3api put-object --bucket "${S3_BUCKET}" --key "sums/${sum}"
@@ -35,13 +35,13 @@ pushd "${tmpdir}"
rm -rf "${dumpfile}"
touch "${dumpfile}"
chmod ugo+w "${dumpfile}"
sudo -u postgres -- pg_dump --no-owner --no-privileges --clean --if-exists --quote-all-identifiers "${DATABASE_URL}" -f "${dumpfile}"
sudo -u postgres -- pg_dump --no-owner --no-privileges --clean --if-exists --quote-all-identifiers "bitwarden_${DATABASE_URL}" -f "${dumpfile}"
"${scriptpath}/pgdump-sort" "${dumpfile}" "sorted.sql"
cp -r "${ROOT_DIR}/data" "./data"
cp "${ROOT_DIR}/.env" "./.env"
cp "${ROOT_DIR}/bitwarden.exceede.com.conf" "./bitwarden.exceede.com.conf"
cp -r "${ROOT_DIR}/data/${DATABASE_URL}" "./data"
cp "${ETC_DIR}/${DATABASE_URL}.conf" "./.env"
cp "${ROOT_DIR}/${DATABASE_URL}.conf" "./${DATABASE_URL}.conf"
rm -rf ./data/icon_cache

View File

@@ -1,10 +0,0 @@
[Unit]
Description=Runs bitwarden backup on a schedule
[Timer]
Unit=backup-bitwarden.service
OnCalendar=hourly
Persistent=true
[Install]
WantedBy=timers.target

View File

@@ -1,8 +1,9 @@
[Unit]
Description=Backup bitwarden configuration, data, and attachments to S3
Description=Backup bitwarden (%i) configuration, data, and attachments to S3
[Service]
EnvironmentFile=/opt/backup/backup-bitwarden.env
Environment=DATABASE_URL=%i
Type=oneshot
ExecStart=/opt/backup/backup-bitwarden.sh
WorkingDirectory=/opt/backup/staging/bitwarden

10
backup-bitwarden@.timer Normal file
View File

@@ -0,0 +1,10 @@
[Unit]
Description=Runs bitwarden backup (%i) on a schedule
[Timer]
Unit=backup-bitwarden@%i.service
OnCalendar=hourly
Persistent=true
[Install]
WantedBy=timers.target