Compare commits
No commits in common. "7f7d38c87e222c3cd000f7d6803a2c46b4df1bab" and "42831948e1002e5820462261dcedd268d3c953b4" have entirely different histories.
7f7d38c87e
...
42831948e1
|
@ -250,7 +250,7 @@ class sunetdrive::script (
|
||||||
if $customer in ['extern', 'gih', 'hkr', 'suni', 'common', 'su', 'lnu'] {
|
if $customer in ['extern', 'gih', 'hkr', 'suni', 'common', 'su', 'lnu'] {
|
||||||
sunet::scriptherder::cronjob { 'makebuckets':
|
sunet::scriptherder::cronjob { 'makebuckets':
|
||||||
ensure => absent,
|
ensure => absent,
|
||||||
cmd => 'bin/true',
|
cmd => 'bin/true',
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sunet::scriptherder::cronjob { 'makebuckets':
|
sunet::scriptherder::cronjob { 'makebuckets':
|
||||||
|
|
|
@ -50,7 +50,7 @@ function do_backup {
|
||||||
rclone mount ${project}:${bucket} ${mountpoint}/ --daemon --allow-other --dir-cache-time 24h
|
rclone mount ${project}:${bucket} ${mountpoint}/ --daemon --allow-other --dir-cache-time 24h
|
||||||
rclone mkdir ${mirror}:${mirrorbucket}
|
rclone mkdir ${mirror}:${mirrorbucket}
|
||||||
duplicity --full-if-older-than 1M --asynchronous-upload --tempdir /mnt --archive-dir /mnt --no-encryption ${mountpoint} rclone://${mirror}:/${mirrorbucket}
|
duplicity --full-if-older-than 1M --asynchronous-upload --tempdir /mnt --archive-dir /mnt --no-encryption ${mountpoint} rclone://${mirror}:/${mirrorbucket}
|
||||||
if [[ "${extra_backup_jobs[${customer}]:+found}" == "found" ]] && [[ -f "${extra_backup_jobs[${customer}]}" ]]; then
|
if [[ "${extra_backup_jobs[${customer}]:+none}" != "none" ]] && [[ -f "${extra_backup_jobs[${customer}]}" ]]; then
|
||||||
${extra_backup_jobs[${customer}]}
|
${extra_backup_jobs[${customer}]}
|
||||||
fi
|
fi
|
||||||
umount ${mountpoint}
|
umount ${mountpoint}
|
||||||
|
|
|
@ -7,16 +7,16 @@ include_userbuckets="<%= @include_userbuckets %>"
|
||||||
container="nextcloud_app_1"
|
container="nextcloud_app_1"
|
||||||
yq="/usr/local/bin/yq"
|
yq="/usr/local/bin/yq"
|
||||||
if ! [[ -x ${yq} ]]; then
|
if ! [[ -x ${yq} ]]; then
|
||||||
pip install yq
|
pip install yq
|
||||||
fi
|
fi
|
||||||
|
|
||||||
declare -a directories
|
declare -a directories
|
||||||
if [[ -n ${1} ]]; then
|
if [[ -n ${1} ]]; then
|
||||||
directories=("${@}")
|
directories=("${@}")
|
||||||
else
|
else
|
||||||
directories+=("Arbetsmaterial")
|
directories+=("Arbetsmaterial")
|
||||||
directories+=("Bevarande")
|
directories+=("Bevarande")
|
||||||
directories+=("Gallringsbart")
|
directories+=("Gallringsbart")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
olddir="${PWD}"
|
olddir="${PWD}"
|
||||||
|
@ -25,31 +25,31 @@ dirty=0
|
||||||
primary=''
|
primary=''
|
||||||
declare -a users=( 'admin' )
|
declare -a users=( 'admin' )
|
||||||
cd "${tempdir}" || echo "Could not cd to tempdir"
|
cd "${tempdir}" || echo "Could not cd to tempdir"
|
||||||
declare -a projects=( $("${yq}" -r '.project_mapping.'"${customer}"'.'"${environment}"'.assigned | "\(.[].project)"' /etc/hiera/data/common.yaml) )
|
declare -a projects=( "${yq}" -r '.project_mapping.'"${customer}"'.'"${environment}"'.assigned | "\(.[].project)"' /etc/hiera/data/common.yaml )
|
||||||
if [[ "${include_userbuckets}" == "true" ]]; then
|
if [[ "${include_userbuckets}" == "true" ]]; then
|
||||||
primary=$("${yq}" -r '.project_mapping.'"${customer}"'.'"${environment}"'.primary_project' /etc/hiera/data/common.yaml)
|
primary=$("${yq}" -r '.project_mapping.'"${customer}"'.'"${environment}"'.primary_project' /etc/hiera/data/common.yaml)
|
||||||
projects+=( "${primary}" )
|
projects+=( "${primary}" )
|
||||||
fi
|
fi
|
||||||
for project in "${projects[@]}"; do
|
for project in "${projects[@]}"; do
|
||||||
for bucket in $(rclone lsd "${project}:" | awk '{print $NF}' | grep -E -v '^primary'); do
|
for bucket in $(rclone lsd "${project}:" | awk '{print $NF}' | grep -E -v '^primary'); do
|
||||||
count=$(rclone size --json "${project}:${bucket}" | jq -r .count)
|
count=$(rclone size --json "${project}:${bucket}" | jq -r .count)
|
||||||
if [[ ${count} -gt 0 ]]; then
|
if [[ ${count} -gt 0 ]]; then
|
||||||
echo "Skipping ${project}:${bucket} because it has stuff in it already"
|
echo "Skipping ${project}:${bucket} because it has stuff in it already"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
for directory in "${directories[@]}"; do
|
for directory in "${directories[@]}"; do
|
||||||
dirty=1
|
dirty=1
|
||||||
if [[ -n ${primary} ]] && [[ ${project} == "${primary}" ]] ; then
|
if [[ -n ${primary} ]] && [[ ${project} == "${primary}" ]] ; then
|
||||||
user=$(echo "${bucket}" | awk -F '-' '{print $1}')
|
user=$(echo "${bucket}" | awk -F '-' '{print $1}')
|
||||||
users+=( "${user}@${eppn_suffix}" )
|
users+=( "${user}@${eppn_suffix}" )
|
||||||
fi
|
fi
|
||||||
echo "Creating ${project}:${bucket}/${directory} because it looks nice and empty"
|
echo "Creating ${project}:${bucket}/${directory} because it looks nice and empty"
|
||||||
temp="README.md"
|
temp="README.md"
|
||||||
echo "**${directory}**" >"${temp}"
|
echo "**${directory}**" >"${temp}"
|
||||||
echo "Var god lämna kvar denna fil/Please leave this file" >>"${temp}"
|
echo "Var god lämna kvar denna fil/Please leave this file" >>"${temp}"
|
||||||
rclone --no-traverse move "${temp}" "${project}:${bucket}/${directory}"
|
rclone --no-traverse move "${temp}" "${project}:${bucket}/${directory}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
cd "${olddir}" || echo "could not cd to home dir"
|
cd "${olddir}" || echo "could not cd to home dir"
|
||||||
rmdir "${tempdir}"
|
rmdir "${tempdir}"
|
||||||
|
|
Loading…
Reference in a new issue