diff --git a/.env b/.env index 650763a..e2e9725 100644 --- a/.env +++ b/.env @@ -12,10 +12,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='your private key between single quotes' +### 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 +38,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' diff --git a/README.md b/README.md index 31196ac..7d7c333 100644 --- a/README.md +++ b/README.md @@ -49,12 +49,18 @@ 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 Fill all needed variables in the `.env` file, it is provided with example values. +* 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). For the first run, the script will initialize the restic repository. 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