Merge branch 'main' into stable
This commit is contained in:
commit
50dcefdb3d
5 changed files with 27 additions and 15 deletions
|
@ -4,7 +4,9 @@ define sunetdrive::db_type(
|
|||
$bootstrap=undef,
|
||||
$location=undef,
|
||||
$override_config = undef,
|
||||
$override_compose = undef)
|
||||
$override_compose = undef,
|
||||
$replicate_rewrite_db = undef,
|
||||
)
|
||||
{
|
||||
|
||||
# Config from group.yaml
|
||||
|
@ -27,8 +29,8 @@ define sunetdrive::db_type(
|
|||
$mysql_user_password = safe_hiera('mysql_user_password')
|
||||
$mariadb_dir = '/etc/mariadb'
|
||||
$mycnf_path = 'sunetdrive/mariadb/my.cnf.erb'
|
||||
$server_id = 1000 + Integer($facts['hostname'][-1])
|
||||
ensure_resource('file',"${mariadb_dir}", { ensure => directory, recurse => true } )
|
||||
$server_id = 1000 + Integer($facts['networking']['hostname'][-1])
|
||||
ensure_resource('file',$mariadb_dir, { ensure => directory, recurse => true } )
|
||||
$dirs = ['datadir', 'init', 'conf', 'backups', 'scripts' ]
|
||||
$dirs.each |$dir| {
|
||||
ensure_resource('file',"${mariadb_dir}/${dir}", { ensure => directory, recurse => true } )
|
||||
|
@ -90,7 +92,7 @@ define sunetdrive::db_type(
|
|||
mode => '0744',
|
||||
}
|
||||
sunet::scriptherder::cronjob { 'purge_binlogs':
|
||||
cmd => "/usr/local/bin/purge-binlogs",
|
||||
cmd => '/usr/local/bin/purge-binlogs',
|
||||
hour => '6',
|
||||
minute => '0',
|
||||
ok_criteria => ['exit_status=0','max_age=2d'],
|
||||
|
@ -109,14 +111,14 @@ define sunetdrive::db_type(
|
|||
content => template('sunetdrive/mariadb/status-test.erb'),
|
||||
mode => '0744',
|
||||
}
|
||||
file { "/etc/sudoers.d/99-size-test":
|
||||
file { '/etc/sudoers.d/99-size-test':
|
||||
ensure => file,
|
||||
content => "script ALL=(root) NOPASSWD: /usr/local/bin/size-test\n",
|
||||
mode => '0440',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
}
|
||||
file { "/etc/sudoers.d/99-status-test":
|
||||
file { '/etc/sudoers.d/99-status-test':
|
||||
ensure => file,
|
||||
content => "script ALL=(root) NOPASSWD: /usr/local/bin/status-test\n",
|
||||
mode => '0440',
|
||||
|
|
|
@ -4,15 +4,17 @@ class sunetdrive::mariadb (
|
|||
$location = undef,
|
||||
$tag_mariadb = undef,
|
||||
$override_config = undef,
|
||||
$override_compose = undef
|
||||
$override_compose = undef,
|
||||
$replicate_rewrite_db = undef,
|
||||
) {
|
||||
|
||||
$quorum_id = $::fqdn
|
||||
$quorum_id = $facts['networking']['fqdn']
|
||||
$quorum_password = safe_hiera('quorum_password')
|
||||
$db = sunetdrive::db_type { 'base_db':
|
||||
bootstrap => $bootstrap,
|
||||
tag_mariadb => $tag_mariadb,
|
||||
location => $location,
|
||||
bootstrap => $bootstrap,
|
||||
tag_mariadb => $tag_mariadb,
|
||||
location => $location,
|
||||
replicate_rewrite_db => $replicate_rewrite_db,
|
||||
}
|
||||
file { '/etc/quorum.conf':
|
||||
ensure => file,
|
||||
|
|
|
@ -19,6 +19,10 @@ gtid_strict_mode = ON
|
|||
log_bin = binlog
|
||||
log_slave_updates = ON
|
||||
server_id = <%= @server_id %>
|
||||
<% if not @replicate_rewrite_db.nil? -%>
|
||||
replicate-rewrite-db = "<%= @replicate_rewrite_db %>->nextcloud"
|
||||
replicate-wild-do-table = <%= @replicate_rewrite_db %>.%
|
||||
<% end -%>
|
||||
|
||||
# Innodb
|
||||
innodb_autoinc_lock_mode = 2
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Add table
Reference in a new issue