From 1348a3b6927a0d6248bca708c4d9739381657305 Mon Sep 17 00:00:00 2001 From: realAP Date: Sun, 26 Jan 2025 18:00:01 +0100 Subject: [PATCH 1/7] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31196ac..656a031 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ When used with Hetzner Storagebox, follow this [guide](https://docs.hetzner.com/ ### 2. Download the script and .env file * `curl -O https://raw.githubusercontent.com/realAP/backup/main/run_backup.sh` -* `curl -0 https://raw.githubusercontent.com/realAP/backup/main/.env` +* `curl -O https://raw.githubusercontent.com/realAP/backup/main/.env` * make the script executable `chmod +x run_backup.sh` ### 3. Set .env file From 4b636acb0d0ed1e5012f1c9523859840d4f4efe8 Mon Sep 17 00:00:00 2001 From: realAP Date: Sun, 26 Jan 2025 20:04:59 +0100 Subject: [PATCH 2/7] add telegram to doc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 656a031..bdb4cb9 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ When used with Hetzner Storagebox, follow this [guide](https://docs.hetzner.com/ ### 3. Set .env file Fill all needed variables in the `.env` file, it is provided with example values. +* For Telegram bot token see [here](https://core.telegram.org/bots/features#creating-a-new-bot) +* For Telegram chat id see [here](https://stackoverflow.com/a/32572159) ### 4. Run Backup Just run the script `./run_backup.sh` the backup will immediately start and repeat every day at 1am (default). From a186fc3e65f9e22d5b359244b5eb8be76949722a Mon Sep 17 00:00:00 2001 From: realAP Date: Sun, 26 Jan 2025 20:18:57 +0100 Subject: [PATCH 3/7] adjust private key var --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 650763a..5472aab 100644 --- a/.env +++ b/.env @@ -15,7 +15,7 @@ SCRIPT_LOG_PATH=/path/to/logfiles ### storagebox settings (needed) ENV_TARGET_DOMAIN=name_of_your_storagebox_domain ENV_TARGET_DOMAIN_USER=login_name_of_your_storagebox -ENV_SSH_PRIVATE_KEY='your private key between single quotes' +ENV_SSH_PRIVATE_KEY_BASE64='your private key between single quotes as base64 encoded string' ### restic (needed) ENV_RESTIC_REPOSITORY_NAME=name_of_your_repository From b58aae3fd8ff36205881ad874c001fd23373bde7 Mon Sep 17 00:00:00 2001 From: realAP Date: Sun, 26 Jan 2025 20:31:18 +0100 Subject: [PATCH 4/7] reorder .env file --- .env | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.env b/.env index 5472aab..5e3df26 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ + ### for run_backup.sh itself not for the image # data in which provisioing places the data to backup, needs to be fullpath # uncomment the line when you don't want to bind any data to the container (optional) @@ -12,10 +13,16 @@ SCRIPT_RESTORE_DATA_TO=/path/to/restore/data # to access log files outside of the container, default not needed (optional) SCRIPT_LOG_PATH=/path/to/logfiles -### storagebox settings (needed) -ENV_TARGET_DOMAIN=name_of_your_storagebox_domain -ENV_TARGET_DOMAIN_USER=login_name_of_your_storagebox -ENV_SSH_PRIVATE_KEY_BASE64='your private key between single quotes as base64 encoded string' +### nextcloud when used +ENV_NC_URL=url_of_your_nextcloud +ENV_NC_USER=your_nextcloud_user +ENV_NC_PASS='password to your nextcloud between single quotes' + +### postgres when used +ENV_POSTGRES_USER="user of your postgres database" +ENV_POSTGRES_PASSWORD="password of your postgres database" +ENV_POSTGRES_DATABASE="name of your postgres database" +ENV_POSTGRES_HOST="host of your postgres database" ### restic (needed) ENV_RESTIC_REPOSITORY_NAME=name_of_your_repository @@ -32,13 +39,7 @@ ENV_CRON='0 1 * * *' ### possible values: "postgres", "nextcloud", "none" ENV_PROVISION_MODE="nextcloud" -### nextcloud when used -ENV_NC_URL=url_of_your_nextcloud -ENV_NC_USER=your_nextcloud_user -ENV_NC_PASS='password to your nextcloud between single quotes' - -### postgres when used -ENV_POSTGRES_USER="user of your postgres database" -ENV_POSTGRES_PASSWORD="password of your postgres database" -ENV_POSTGRES_DATABASE="name of your postgres database" -ENV_POSTGRES_HOST="host of your postgres database" +### storagebox settings (needed) +ENV_TARGET_DOMAIN=name_of_your_storagebox_domain +ENV_TARGET_DOMAIN_USER=login_name_of_your_storagebox +ENV_SSH_PRIVATE_KEY_BASE64='your private key between single quotes as base64 encoded string' \ No newline at end of file From c62d1769f86bbb151678165c063ac7be82fe2666 Mon Sep 17 00:00:00 2001 From: realAP Date: Sun, 26 Jan 2025 20:54:24 +0100 Subject: [PATCH 5/7] empty line is important in the end --- .env | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.env b/.env index 5e3df26..e2e9725 100644 --- a/.env +++ b/.env @@ -1,4 +1,3 @@ - ### for run_backup.sh itself not for the image # data in which provisioing places the data to backup, needs to be fullpath # uncomment the line when you don't want to bind any data to the container (optional) @@ -42,4 +41,4 @@ ENV_PROVISION_MODE="nextcloud" ### storagebox settings (needed) ENV_TARGET_DOMAIN=name_of_your_storagebox_domain ENV_TARGET_DOMAIN_USER=login_name_of_your_storagebox -ENV_SSH_PRIVATE_KEY_BASE64='your private key between single quotes as base64 encoded string' \ No newline at end of file +ENV_SSH_PRIVATE_KEY_BASE64='your private key between single quotes as base64 encoded string' From a671fea40144db80127bb39580649ef5c13ca7de Mon Sep 17 00:00:00 2001 From: realAP Date: Sun, 26 Jan 2025 20:54:35 +0100 Subject: [PATCH 6/7] add decoding --- docker/prepare_ssh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/prepare_ssh.sh b/docker/prepare_ssh.sh index f4cbf92..2dfe04c 100644 --- a/docker/prepare_ssh.sh +++ b/docker/prepare_ssh.sh @@ -11,7 +11,7 @@ fi ssh-keyscan -t rsa $TARGET_DOMAIN > /etc/ssh/ssh_known_hosts # Create the private key file -echo "$SSH_PRIVATE_KEY" > /private_key +echo "$SSH_PRIVATE_KEY" | base64 --decode > /private_key chmod 600 /private_key # Create the ssh_config file From 041e91065786a27843d870206a9c30bc8d564e9e Mon Sep 17 00:00:00 2001 From: realAP Date: Sun, 26 Jan 2025 20:54:46 +0100 Subject: [PATCH 7/7] adjustments for private key --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bdb4cb9..7d7c333 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,12 @@ When used with Hetzner Storagebox, follow this [guide](https://docs.hetzner.com/ ### 3. Set .env file Fill all needed variables in the `.env` file, it is provided with example values. -* For Telegram bot token see [here](https://core.telegram.org/bots/features#creating-a-new-bot) -* For Telegram chat id see [here](https://stackoverflow.com/a/32572159) + +* For ``ENV_TELEGRAM_TOKEN`` token see [here](https://core.telegram.org/bots/features#creating-a-new-bot) +* For ``ENV_TELEGRAM_CHAT_ID`` see [here](https://stackoverflow.com/a/32572159) +* For ``ENV_SSH_PRIVATE_KEY_BASE64`` you can use the following command to get the base64 encoded private key in the `.env` file + * ``echo "ENV_SSH_PRIVATE_KEY_BASE=$(cat | base64)" >> .env`` + * ATTENTION: you have to remove the template key in the `.env` file afterward ### 4. Run Backup Just run the script `./run_backup.sh` the backup will immediately start and repeat every day at 1am (default).