feat: enabled multi-domain setup
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
staging/bitwarden/
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
ROOT_DIR=/opt/bitwardenrs
|
ROOT_DIR=/opt/bitwardenrs
|
||||||
|
ETC_DIR=/etc/bitwardenrs
|
||||||
S3_BUCKET=bitwarden.exceede.com
|
S3_BUCKET=bitwarden.exceede.com
|
||||||
DATABASE_URL=bitwarden
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function check_for_hash() {
|
|||||||
function create_and_upload() {
|
function create_and_upload() {
|
||||||
local sum=$1
|
local sum=$1
|
||||||
local backup_file
|
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}"
|
echo "Uploading ${backup_file}"
|
||||||
tar -zc . | aws s3 cp - "s3://${S3_BUCKET}/${backup_file}"
|
tar -zc . | aws s3 cp - "s3://${S3_BUCKET}/${backup_file}"
|
||||||
aws s3api put-object --bucket "${S3_BUCKET}" --key "sums/${sum}"
|
aws s3api put-object --bucket "${S3_BUCKET}" --key "sums/${sum}"
|
||||||
@@ -35,13 +35,13 @@ pushd "${tmpdir}"
|
|||||||
rm -rf "${dumpfile}"
|
rm -rf "${dumpfile}"
|
||||||
touch "${dumpfile}"
|
touch "${dumpfile}"
|
||||||
chmod ugo+w "${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"
|
"${scriptpath}/pgdump-sort" "${dumpfile}" "sorted.sql"
|
||||||
|
|
||||||
cp -r "${ROOT_DIR}/data" "./data"
|
cp -r "${ROOT_DIR}/data/${DATABASE_URL}" "./data"
|
||||||
cp "${ROOT_DIR}/.env" "./.env"
|
cp "${ETC_DIR}/${DATABASE_URL}.conf" "./.env"
|
||||||
cp "${ROOT_DIR}/bitwarden.exceede.com.conf" "./bitwarden.exceede.com.conf"
|
cp "${ROOT_DIR}/${DATABASE_URL}.conf" "./${DATABASE_URL}.conf"
|
||||||
|
|
||||||
rm -rf ./data/icon_cache
|
rm -rf ./data/icon_cache
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Backup bitwarden configuration, data, and attachments to S3
|
Description=Backup bitwarden (%i) configuration, data, and attachments to S3
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=/opt/backup/backup-bitwarden.env
|
EnvironmentFile=/opt/backup/backup-bitwarden.env
|
||||||
|
Environment=DATABASE_URL=%i
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/opt/backup/backup-bitwarden.sh
|
ExecStart=/opt/backup/backup-bitwarden.sh
|
||||||
WorkingDirectory=/opt/backup/staging/bitwarden
|
WorkingDirectory=/opt/backup/staging/bitwarden
|
||||||
10
backup-bitwarden@.timer
Normal file
10
backup-bitwarden@.timer
Normal 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
|
||||||
Reference in New Issue
Block a user