Commit graph

418 commits

Author SHA1 Message Date
Micke Nordin 174c72eb70
BACKUPDB: Fix bug that put backup in a file instead of a directory
We found a bug that moved the backups to a file, but we want that to be
a directory, meaning that all the files were overwritten one by one, and
we were not taking the backups as we though.
2023-09-12 16:19:17 +02:00
Micke Nordin b989bd3d54
Hide deprecation warnings in Ubuntu 20.04 2023-09-08 07:39:34 +02:00
Micke Nordin 234d19b652
Merge branch 'main' into stable 2023-09-02 14:16:48 +02:00
Micke Nordin 22f5dfac62
Allways backup before restarting 2023-09-02 12:50:08 +02:00
Micke Nordin 1b60d41dab
Get password 2023-09-02 12:38:34 +02:00
Micke Nordin 7207ef2bbf
Allways backup the db 2023-09-02 12:30:16 +02:00
Micke Nordin c7bd0fa965
Try again 2023-09-02 12:19:33 +02:00
Micke Nordin d540c90afa
Try again 2023-09-02 12:15:54 +02:00
Micke Nordin b927716aad
Fix comment 2023-09-02 12:12:59 +02:00
Micke Nordin ac6430df51
Add announce script to script servers 2023-09-02 12:08:17 +02:00
Micke Nordin 88b3c1b4fb
Merge branch 'main' into testing 2023-09-02 09:29:06 +02:00
Micke Nordin 5bc0ddfa00
Add admin password as env variable to image 2023-09-02 09:28:39 +02:00
Micke Nordin 99c88c0c3b
Dont redeclare 2023-08-22 17:24:38 +02:00
Micke Nordin 8bfa2d58a9
Merge branch 'main' into stable 2023-08-22 17:15:00 +02:00
Micke Nordin 3b58bcd2ae
Get drive customers 2023-08-22 17:14:07 +02:00
Micke Nordin 364a8685a7
Get drive customers 2023-08-22 17:13:02 +02:00
Micke Nordin 3bd7a44d7a Merge branch 'main' into testing 2023-08-16 12:55:35 +02:00
Micke Nordin f56a5c6eae Add get drive customers script to all servers 2023-08-16 12:53:08 +02:00
Micke Nordin feb02cc2cc
Merge branch 'main' into testing 2023-07-25 13:38:12 +02:00
Micke Nordin 58fd21e0aa
Typo 2023-07-25 13:37:56 +02:00
Micke Nordin 1e0879769c
Merge branch 'main' into testing 2023-07-25 13:35:46 +02:00
Micke Nordin 3986e69349
See if we can get ipv6 for monitor 2023-07-25 13:35:31 +02:00
Micke Nordin d0ca012129
Merge branch 'main' into stable 2023-07-25 08:15:40 +02:00
Micke Nordin 753512f90f
Merge branch 'main' into testing 2023-07-20 11:24:06 +02:00
Micke Nordin 598be8c2f1
Add full support for common infra 2023-07-20 11:23:48 +02:00
Micke Nordin 1cea9c9173
Remove replicate readwrite db 2023-07-18 15:59:47 +02:00
Micke Nordin 6df092764f
Remove replicate readwrite db 2023-07-18 15:59:08 +02:00
Micke Nordin 735eaf7067
Merge branch 'main' into testing 2023-07-18 15:53:04 +02:00
Micke Nordin 54de0adb0f
Remove replicate readwrite db 2023-07-18 15:52:33 +02:00
Micke Nordin 42b57f3655
Merge branch 'main' into stable 2023-07-18 11:13:19 +02:00
Micke Nordin ed9353198d
Merge branch 'main' into testing 2023-07-06 14:51:04 +02:00
Micke Nordin 1152fd972f
Add 'gss.username_format' => 'sanitize', 2023-07-06 14:50:47 +02:00
Micke Nordin 604d485d29
Fix gss_mode for multinode 2023-06-28 15:53:13 +02:00
Micke Nordin c7072d6dae
Fix gss_mode for multinode 2023-06-28 15:52:52 +02:00
Micke Nordin 3281824eac
Fix gss_mode for multinode 2023-06-28 15:51:43 +02:00
Micke Nordin df1277e04e
Merge branch 'main' into stable 2023-06-15 19:27:15 +02:00
Micke Nordin b15bc5ad03
Merge branch 'main' into testing 2023-06-15 19:24:58 +02:00
Micke Nordin befc3207d9
Fix conficting bashrc declarations 2023-06-15 19:24:31 +02:00
Micke Nordin b166a683a6
Merge branch 'main' into stable 2023-06-15 18:32:53 +02:00
Micke Nordin bffb06333d
Merge branch 'main' into testing 2023-06-15 12:01:19 +02:00
Micke Nordin bc329be450
Add back safer_reboot 2023-06-15 12:00:47 +02:00
Micke Nordin 1e23d134f1
Add fqdn to PS1 2023-06-13 14:15:53 +02:00
Micke Nordin 50dcefdb3d
Merge branch 'main' into stable 2023-06-13 12:17:46 +02:00
Micke Nordin ff3a5c143c
Pass on vaiables 2023-06-13 12:16:55 +02:00
Micke Nordin e0139b0765
BAckups: Fix db backups
DB backup dir clashed with statistics script storage location, and also
some permission errors.

diff --git a/templates/script/backupdb.erb.sh b/templates/script/backupdb.erb.sh
index b35acbc..1eb7992 100644
--- a/templates/script/backupdb.erb.sh
+++ b/templates/script/backupdb.erb.sh
@@ -6,11 +6,16 @@ sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk
 number_of_full_to_keep="<%= @full_backup_retention %>"

 backup="${1}"
+if [[ -z ${backup} ]]; then
+  backup="backup1.$(hostname -d)"
+fi
 if ! [[ ${backup} =~ backup1.*sunet.se$ ]]; then
 	echo "Usage: ${0} <fqdn of backup server>"
 	echo "Example: ${0} backup1.sunet.drive.sunet.se"
 fi
 backup_dir="/opt/backups"
+backup_dir_long="${backup_dir}/backups"
+mkdir -p ${backup_dir}
 bucket="db-backups"
 mirror="<%= @customer %>-<%= @environment %>-mirror"
 if [[ ${mirror} =~ common-(test|prod)-mirror ]]; then
@@ -23,11 +28,8 @@ ssh ${backup} "sudo /home/script/bin/backup_db.sh"
 echo "Cleaning up old backups for ${backup}"
 ssh ${backup} "sudo /home/script/bin/purge_backups.sh /opt/mariadb_backup/backups/"
 echo "Copying backups here"
-mkdir -p ${backup_dir}
-scp script@${backup}:/opt/mariadb_backup/backups/$(date +%Y/%m/%d)/*.gz ${backup_dir}
+scp script@${backup}:/opt/mariadb_backup/backups/$(date +%Y/%m/%d)/*.gz ${backup_dir_long}
 echo "Copying backups to remote bucket"
 rclone mkdir ${mirror}:${bucket}
 duplicity --full-if-older-than 1M --tempdir /mnt --archive-dir /mnt --no-encryption ${backup_dir} rclone://${mirror}:/${bucket}
 duplicity remove-all-but-n-full ${number_of_full_to_keep} --tempdir /mnt --archive-dir /mnt --force rclone://${mirror}:/${bucket}
-echo "cleaning up"
-rm -r ${backup_dir}
diff --git a/templates/scriptreceiver/backup_db.erb.sh b/templates/scriptreceiver/backup_db.erb.sh
index 025a338..3e15f25 100644
--- a/templates/scriptreceiver/backup_db.erb.sh
+++ b/templates/scriptreceiver/backup_db.erb.sh
@@ -11,5 +11,7 @@ else
 fi

 docker exec ${container} /do_backup.sh ${customer}
+chown root:script /opt/mariadb_backup/
+chmod 750 /opt/mariadb_backup/
 chmod 755 ${backupdir}
 chown -R script:root ${backupdir}
2023-06-13 12:15:19 +02:00
Micke Nordin fa93c01846
Fix permissions 2023-06-13 12:09:13 +02:00
Micke Nordin a9fdb43bf6
Add a default for backup 2023-06-13 11:59:19 +02:00
Micke Nordin 95030efba2
Run backup on same dir as before 2023-06-13 11:52:15 +02:00
Micke Nordin 2119f71008
Backup dir overwritten by data script 2023-06-13 11:46:25 +02:00
Micke Nordin 08243f555d
Add back index 2023-06-12 11:42:00 +02:00