Compare commits
No commits in common. "f21a489e460045f7ba9f94753f29223591c1935c" and "16496dfded2936330d664d8ad21a2a7d87ac4c3e" have entirely different histories.
f21a489e46
...
16496dfded
|
@ -20,7 +20,6 @@ class sunetdrive::script (
|
||||||
$local_path = '/tmp/rclone-current-linux-amd64.deb'
|
$local_path = '/tmp/rclone-current-linux-amd64.deb'
|
||||||
$singlenodes = lookup('singlenodes')
|
$singlenodes = lookup('singlenodes')
|
||||||
$multinodes = keys(lookup('multinode_mapping'))
|
$multinodes = keys(lookup('multinode_mapping'))
|
||||||
$extra_backup_jobs = pick($config['extra_backup_jobs'], {})
|
|
||||||
|
|
||||||
if $customer == 'mdu' {
|
if $customer == 'mdu' {
|
||||||
$eppn_suffix = 'mdh.se'
|
$eppn_suffix = 'mdh.se'
|
||||||
|
|
|
@ -64,7 +64,7 @@ class sunetdrive::scriptreceiver()
|
||||||
}
|
}
|
||||||
file { '/root/.bashrc':
|
file { '/root/.bashrc':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
content => template('sunetdrive/scriptreceiver/bashrc.erb.sh'),
|
content => template('sunetdrive/scriptreceiver/baschrc.erb.sh'),
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
owner => 'root',
|
owner => 'root',
|
||||||
group => 'root',
|
group => 'root',
|
||||||
|
|
|
@ -47,12 +47,6 @@ class sunetdrive::sitemonitornaemon() {
|
||||||
content => template('sunetdrive/monitor/sunetdrive_thruk_templates.conf.erb'),
|
content => template('sunetdrive/monitor/sunetdrive_thruk_templates.conf.erb'),
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
}
|
}
|
||||||
nagioscfg::service {'check_scriptherder':
|
|
||||||
hostgroup_name => ['nrpe'],
|
|
||||||
check_command => 'check_nrpe_1arg_to30!check_scriptherder',
|
|
||||||
description => 'Scriptherder Status',
|
|
||||||
contact_groups => ['naemon-admins'],
|
|
||||||
}
|
|
||||||
nagioscfg::service {'check_galera_cluster':
|
nagioscfg::service {'check_galera_cluster':
|
||||||
hostgroup_name => ['galera_monitor'],
|
hostgroup_name => ['galera_monitor'],
|
||||||
check_command => 'check_nrpe_1arg!check_galera_cluster',
|
check_command => 'check_nrpe_1arg!check_galera_cluster',
|
||||||
|
|
|
@ -15,16 +15,9 @@ password=$(${dexec} env | grep MYSQL_ROOT_PASSWORD | awk -F '=' '{print $2}')
|
||||||
|
|
||||||
mysql="${dexec} mysql -p${password}"
|
mysql="${dexec} mysql -p${password}"
|
||||||
|
|
||||||
if [[ "$(${mysql} -NB -e 'select exists(select * from information_schema.TABLES where TABLE_SCHEMA = "nextcloud" and TABLE_NAME = "oc_global_scale_users")')" == "1" ]]
|
|
||||||
then
|
|
||||||
users="$(${mysql} -NB -e 'select uid,displayname from nextcloud.oc_global_scale_users')"
|
users="$(${mysql} -NB -e 'select uid,displayname from nextcloud.oc_global_scale_users')"
|
||||||
fi
|
users="${users}
|
||||||
users="${users}"$'\n'"$(${mysql} -NB -e 'select uid,displayname from nextcloud.oc_users')"
|
$(${mysql} -NB -e 'select uid,displayname from nextcloud.oc_users')"
|
||||||
if [[ "$(${mysql} -NB -e 'select exists(select * from information_schema.TABLES where TABLE_SCHEMA = "nextcloud" and TABLE_NAME = "oc_user_saml_users")')" == "1" ]]
|
|
||||||
then
|
|
||||||
users="${users}"$'\n'"$(${mysql} -NB -e 'select uid,displayname from nextcloud.oc_user_saml_users')"
|
|
||||||
fi
|
|
||||||
users="$(echo "${users}" | sort | uniq)"
|
|
||||||
|
|
||||||
project="statistics"
|
project="statistics"
|
||||||
bucket="drive-server-coms"
|
bucket="drive-server-coms"
|
||||||
|
|
|
@ -6,12 +6,6 @@ sleep $((16#$(ip a | grep "link/ether" | head -1 | awk -F ':' '{print $6}' | awk
|
||||||
number_of_full_to_keep='<%= @full_backup_retention %>'
|
number_of_full_to_keep='<%= @full_backup_retention %>'
|
||||||
fork_limit=30 #in GB, if bigger than this number, we fork the backup to it's own process
|
fork_limit=30 #in GB, if bigger than this number, we fork the backup to it's own process
|
||||||
customer="<%= @customer %>"
|
customer="<%= @customer %>"
|
||||||
declare -A extra_backup_jobs
|
|
||||||
#<% if @extra_backup_jobs.any? %>
|
|
||||||
#<% @extra_backup_jobs.each do |client, job| %>
|
|
||||||
extra_backup_jobs["<%= client %>"]="<%= job %>"
|
|
||||||
#<% end %>
|
|
||||||
#<% end %>
|
|
||||||
#<% if @location.start_with?('common') %>
|
#<% if @location.start_with?('common') %>
|
||||||
declare -a sixmonths=('mau')
|
declare -a sixmonths=('mau')
|
||||||
if [[ " ${sixmonths[*]} " =~ " ${customer} " ]]; then
|
if [[ " ${sixmonths[*]} " =~ " ${customer} " ]]; then
|
||||||
|
@ -19,20 +13,20 @@ if [[ " ${sixmonths[*]} " =~ " ${customer} " ]]; then
|
||||||
fi
|
fi
|
||||||
declare -a projects
|
declare -a projects
|
||||||
#<% @singlenodes.each do |singlenode| %>
|
#<% @singlenodes.each do |singlenode| %>
|
||||||
projects+=("<%= @full_project_mapping[singlenode][@environment]['primary_project'] %> <%= @full_project_mapping[singlenode][@environment]['mirror_project'] %> <%= singlenode %>")
|
projects+=("<%= @full_project_mapping[singlenode][@environment]['primary_project'] %> <%= @full_project_mapping[singlenode][@environment]['mirror_project'] %>")
|
||||||
#<% @full_project_mapping[singlenode][@environment]['assigned'].each do |project| %>
|
#<% @full_project_mapping[singlenode][@environment]['assigned'].each do |project| %>
|
||||||
projects+=("<%= project['project'] %> <%= project['mirror_project'] %> <%= singlenode %>")
|
projects+=("<%= project['project'] %> <%= project['mirror_project'] %>")
|
||||||
#<% end %>
|
#<% end %>
|
||||||
#<% end %>
|
#<% end %>
|
||||||
#<% else %>
|
#<% else %>
|
||||||
declare -a projects=("<%= @primary_project %> <%= @mirror_project %> <%= customer %>")
|
declare -a projects=("<%= @primary_project %> <%= @mirror_project %>")
|
||||||
#<% @assigned_projects.each do |project| %>
|
#<% @assigned_projects.each do |project| %>
|
||||||
projects+=("<%= project['project'] %> <%= project['mirror_project'] %> <%= customer %>")
|
projects+=("<%= project['project'] %> <%= project['mirror_project'] %>")
|
||||||
#<% end %>
|
#<% end %>
|
||||||
#<% end %>
|
#<% end %>
|
||||||
|
|
||||||
if [[ ${customer} == 'common' ]]; then
|
if [[ ${customer} == 'common' ]]; then
|
||||||
projects+=("<%= @location %> <%= @location %>-mirror ${customer}")
|
projects+=("<%= @location %> <%= @location %>-mirror")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,17 +34,15 @@ function do_backup {
|
||||||
local project="${1}"
|
local project="${1}"
|
||||||
local mirror="${2}"
|
local mirror="${2}"
|
||||||
local bucket="${3}"
|
local bucket="${3}"
|
||||||
local customer="${4}"
|
|
||||||
local mirrorbucket="${bucket}-mirror"
|
local mirrorbucket="${bucket}-mirror"
|
||||||
local mountpoint="/opt/backupmounts/${bucket}"
|
local mountpoint="/opt/backupmounts/${bucket}"
|
||||||
ps aux | grep duplicity | grep "[^a-zA-Z]${bucket}" > /dev/null
|
ps aux | grep duplicity | grep "[^a-zA-Z]${bucket}" > /dev/null
|
||||||
local oktorun=$? # 1 == this bucket has no other bakup process in progress
|
local oktorun=$? # 1 == this bucket has no other bakup process in progress
|
||||||
mkdir -p ${mountpoint}
|
mkdir -p ${mountpoint}
|
||||||
[[ ${oktorun} -ne 0 ]] && rclone mount ${project}:${bucket} ${mountpoint}/ --daemon --allow-other --dir-cache-time 24h
|
[ ${oktorun} -ne 0 ] && rclone mount ${project}:${bucket} ${mountpoint}/ --daemon --allow-other --dir-cache-time 24h
|
||||||
rclone mkdir ${mirror}:${mirrorbucket}
|
rclone mkdir ${mirror}:${mirrorbucket}
|
||||||
[[ ${oktorun} -ne 0 ]] && duplicity --full-if-older-than 1M --asynchronous-upload --tempdir /mnt --archive-dir /mnt \
|
[ ${oktorun} -ne 0 ] && duplicity --full-if-older-than 1M --asynchronous-upload --tempdir /mnt --archive-dir /mnt \
|
||||||
--no-encryption ${mountpoint} rclone://${mirror}:/${mirrorbucket} && \
|
--no-encryption ${mountpoint} rclone://${mirror}:/${mirrorbucket}
|
||||||
[[ -n "${extra_backup_jobs[${customer}]}" ]] && [[ -f ${extra_backup_jobs[${customer} ]] && ${extra_backup_jobs[${customer}]}
|
|
||||||
umount ${mountpoint}
|
umount ${mountpoint}
|
||||||
rmdir ${mountpoint}
|
rmdir ${mountpoint}
|
||||||
# Clean up
|
# Clean up
|
||||||
|
@ -61,7 +53,6 @@ function do_backup {
|
||||||
for entry in "${projects[@]}"; do
|
for entry in "${projects[@]}"; do
|
||||||
project=$(echo ${entry} | awk '{print $1}')
|
project=$(echo ${entry} | awk '{print $1}')
|
||||||
mirror=$(echo ${entry} | awk '{print $2}')
|
mirror=$(echo ${entry} | awk '{print $2}')
|
||||||
customer=$(echo ${entry} | awk '{print $3}')
|
|
||||||
for bucket in $(rclone lsd ${project}:/ | awk '{print $5}'); do
|
for bucket in $(rclone lsd ${project}:/ | awk '{print $5}'); do
|
||||||
maybesize=$(timeout 30s rclone size --json ${project}:${bucket})
|
maybesize=$(timeout 30s rclone size --json ${project}:${bucket})
|
||||||
if [[ ${?} -eq 124 ]]; then
|
if [[ ${?} -eq 124 ]]; then
|
||||||
|
@ -71,9 +62,9 @@ for entry in "${projects[@]}"; do
|
||||||
fi
|
fi
|
||||||
# If bucket is above 50 GB we fork
|
# If bucket is above 50 GB we fork
|
||||||
if [[ ${size} -gt $((${fork_limit} * 1000000000)) ]]; then
|
if [[ ${size} -gt $((${fork_limit} * 1000000000)) ]]; then
|
||||||
do_backup ${project} ${mirror} ${bucket} ${customer} &
|
do_backup ${project} ${mirror} ${bucket} &
|
||||||
else
|
else
|
||||||
do_backup ${project} ${mirror} ${bucket} ${customer}
|
do_backup ${project} ${mirror} ${bucket}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue