From 2f97785cba155f30001c3072a0c4a9becd981b51 Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 20:33:22 +0100 Subject: [PATCH 1/8] Update readme --- README.MD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index 6ddec2c..cb68b07 100644 --- a/README.MD +++ b/README.MD @@ -77,8 +77,8 @@ Todo ### etc/systemd/system/make-backup.service Systemd service to make backup. -```WorkingDirectory=``` should be the absolute path to where make_backup.sh script is located. -```ExecStart=``` *MUST* be the absolute path to make_backup.sh +```WorkingDirectory=``` should be the absolute path to where make_backup.sh script is located. +```ExecStart=``` *MUST* be the absolute path to make_backup.sh ### etc/systemd/system/make-backup.timer Systemd timer to trigger backup. From 6a5a146d7cea13a17b3bc3168bcab627e2e213fb Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 20:38:21 +0100 Subject: [PATCH 2/8] Readme, .timer OnCalendar --- README.MD | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index cb68b07..d1cc943 100644 --- a/README.MD +++ b/README.MD @@ -77,13 +77,14 @@ Todo ### etc/systemd/system/make-backup.service Systemd service to make backup. -```WorkingDirectory=``` should be the absolute path to where make_backup.sh script is located. -```ExecStart=``` *MUST* be the absolute path to make_backup.sh +```WorkingDirectory=``` should be the absolute path to where ```make_backup.sh``` script is located. +```ExecStart=``` *MUST* be the absolute path to ```make_backup.sh``` ### etc/systemd/system/make-backup.timer Systemd timer to trigger backup. When backups are made is defined in the line: ```OnCalendar=Mon-Sun *-*-* 04:00:00``` +This currently does a backup at 04:00 every day (Monday to Sunday), it could also be expressed by ```OnCalendar=daily``` but this would always trigger at ```00:00:00``` See ```man systemd.time``` for more how to configure OnCalendar events. ### Systemd service+timer install From a51ac9be6fbf341a0b6fa8dbfbb8337a72732075 Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 20:58:39 +0100 Subject: [PATCH 3/8] README, systemd.timer --- README.MD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.MD b/README.MD index d1cc943..7548348 100644 --- a/README.MD +++ b/README.MD @@ -83,8 +83,8 @@ Systemd service to make backup. ### etc/systemd/system/make-backup.timer Systemd timer to trigger backup. When backups are made is defined in the line: -```OnCalendar=Mon-Sun *-*-* 04:00:00``` -This currently does a backup at 04:00 every day (Monday to Sunday), it could also be expressed by ```OnCalendar=daily``` but this would always trigger at ```00:00:00``` +```OnCalendar= 04:00``` +This currently does a backup at 04:00 every day, it could also be expressed by ```OnCalendar=daily``` but this would always trigger at ```00:00:00``` See ```man systemd.time``` for more how to configure OnCalendar events. ### Systemd service+timer install From 7ef513b21e993d3cb5fa330ca024c199ffed0cf3 Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 21:01:44 +0100 Subject: [PATCH 4/8] README, email secrets.env --- README.MD | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.MD b/README.MD index 7548348..659a907 100644 --- a/README.MD +++ b/README.MD @@ -72,8 +72,18 @@ Todo ### secrets.env +Contains mailserver configuration in an oldschool INI file format. +``` +[MAIL] +SERVER = mail.example.com +PORT = 587 +USER = service_notify@example.com +PASS = aelaGhuye8Co9cah7aighoo3oongohS4 +``` +Just configure your servername, port, username and password. +This is setup for SMTP startls authentication. +If you use something else and get it working, let me know. -Todo ### etc/systemd/system/make-backup.service Systemd service to make backup. From ded7406d40307dd8f63cc19b0a443aa8b968a22e Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 21:12:04 +0100 Subject: [PATCH 5/8] README, email secrets.env --- README.MD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index 659a907..a3b3c42 100644 --- a/README.MD +++ b/README.MD @@ -66,9 +66,8 @@ Todo Todo -### mail_template.py - -Todo +### mail_template.py +File containing email template as well as ### secrets.env @@ -84,6 +83,7 @@ Just configure your servername, port, username and password. This is setup for SMTP startls authentication. If you use something else and get it working, let me know. +Allow me to repeat... KEEP THIS SECRET, you don't want someone to abuse your email. ### etc/systemd/system/make-backup.service Systemd service to make backup. From 187e745294ea2422ad08826471dd8292b51fe446 Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 21:16:16 +0100 Subject: [PATCH 6/8] README, mail_template.py and LASTLOG environment variable. --- README.MD | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.MD b/README.MD index a3b3c42..777d90a 100644 --- a/README.MD +++ b/README.MD @@ -67,7 +67,16 @@ Todo ### mail_template.py -File containing email template as well as +File containing email template as well as subject and list of email recievers. +``` +recivers = ["example@example.com", "example2@example.com"] +subject = f"Backup on \"{HOSTNAME}\", for SERVICE complete." +``` +Recivers is a python list of email addresses, a seperate email will be sent to each reciever. +Subject is the subjectline of the email being sent (surprise!). + +It is made to be called by ```make_backup.sh``` and expects the LASTLOG environment variable to be set. +LASTLOG points to a a logfile containing only the result of the latest backup done. ### secrets.env From 1f0d4b79c7a1f666d71cd6c0436dd941c2f05f75 Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 21:32:40 +0100 Subject: [PATCH 7/8] README, backup_exclude.txt --- README.MD | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index 777d90a..dc76499 100644 --- a/README.MD +++ b/README.MD @@ -53,9 +53,9 @@ Keep it safe and secure. DO NOT USE THIS AS YOUR PASSPHRASE. (And no, this is NOT my passphrase, it is some random garbage) -### backup_exclude.txt - -Todo +### backup_exclude.txt +A file containing files/directories that should NOT be included in the backup, this can be tmpfiles, virtual filesystems or mounted network devices that might not always be thre or inflate the backup size. +A good "default" exclude file is included in ```backup_exclude.txt.sample``` ### init_backup.sh From c5aed3acc4c786baa58fbbcd4e3991da14a6ace4 Mon Sep 17 00:00:00 2001 From: Adam Rabjerg Date: Mon, 22 Mar 2021 21:42:25 +0100 Subject: [PATCH 8/8] README, init_backup and make_bakup. --- README.MD | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/README.MD b/README.MD index dc76499..29aee6b 100644 --- a/README.MD +++ b/README.MD @@ -4,9 +4,9 @@ This repository contains some helper scripts to get you started with making back Everything is controlled by .env files. -### Files +# Files -#### backup.env +## backup.env copy the file backup.env.sample to backup.env and start configuring it to your liking. @@ -53,20 +53,22 @@ Keep it safe and secure. DO NOT USE THIS AS YOUR PASSPHRASE. (And no, this is NOT my passphrase, it is some random garbage) -### backup_exclude.txt -A file containing files/directories that should NOT be included in the backup, this can be tmpfiles, virtual filesystems or mounted network devices that might not always be thre or inflate the backup size. +## backup_exclude.txt +A file containing files/directories that should NOT be included in the backup, this can be tmpfiles, virtual filesystems or mounted network devices that might not always be there or inflate the backup size. A good "default" exclude file is included in ```backup_exclude.txt.sample``` -### init_backup.sh +## init_backup.sh +An interactive helper script to get you started, this includes creating ssh keys, collecting information for your backup.env file and much more. +Have your server/login information ready and follow carefully, if at any point there is issues you should interrupt and correct before retrying. +When everything goes well it will in the end initialize the remote repository for you, once that is done you are ready to take backups once the settings shown are transferred to your ```.env``` file. -Todo - -### make_backup.sh - -Todo +## make_backup.sh +Once repository is initialized with ```init_backup.sh``` and your ```.env``` file is filled, you can make your first backup. +This file is the "meat" of your backup, it is responsilbe (together with your ```.env``` file) for making the backups. +In the end the ```mail_template.py``` is called to send you an email, this can be commented out if you want to supress emails (this should be a setting in .env). -### mail_template.py +## mail_template.py File containing email template as well as subject and list of email recievers. ``` recivers = ["example@example.com", "example2@example.com"] @@ -79,7 +81,7 @@ It is made to be called by ```make_backup.sh``` and expects the LASTLOG environm LASTLOG points to a a logfile containing only the result of the latest backup done. -### secrets.env +## secrets.env Contains mailserver configuration in an oldschool INI file format. ``` [MAIL] @@ -94,19 +96,19 @@ If you use something else and get it working, let me know. Allow me to repeat... KEEP THIS SECRET, you don't want someone to abuse your email. -### etc/systemd/system/make-backup.service +## etc/systemd/system/make-backup.service Systemd service to make backup. ```WorkingDirectory=``` should be the absolute path to where ```make_backup.sh``` script is located. ```ExecStart=``` *MUST* be the absolute path to ```make_backup.sh``` -### etc/systemd/system/make-backup.timer +## etc/systemd/system/make-backup.timer Systemd timer to trigger backup. When backups are made is defined in the line: ```OnCalendar= 04:00``` This currently does a backup at 04:00 every day, it could also be expressed by ```OnCalendar=daily``` but this would always trigger at ```00:00:00``` See ```man systemd.time``` for more how to configure OnCalendar events. -### Systemd service+timer install +## Systemd service+timer install Configure the trigger in the .timer, remember to change "Description" in both .service and .timer. ```systemd-analyze verify make-backup.*```