Skip to content

Commit 8122a97

Browse files
committed
PR changes
Create usage function in backup script Remove extra blank line Correct usage and remove spurious comment in vacuum script
1 parent f45468f commit 8122a97

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

files/puppet_enterprise_database_backup.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
usage() {
4+
echo "usage: $0 [-t BACKUP_TARGET] [-l LOG_DIRECTORY] [-r retention] <DATABASE> [DATABASE_N ...]"
5+
exit 1
6+
}
7+
38
while [[ $1 ]]; do
49
case "$1" in
510
-t)
@@ -30,10 +35,7 @@ done
3035
databases=("$@")
3136
# shellcheck disable=SC2128
3237
# We only care if the array contains any elements
33-
[[ $databases ]] || {
34-
echo "Usage: $0 [-t BACKUP_TARGET] [-l LOG_DIRECTORY] [-r retention] <DATABASE> [DATABASE_N ...]"
35-
exit 1
36-
}
38+
[[ $databases ]] || usage
3739

3840
[[ $pg_version ]] || pg_version="$(/usr/local/bin/facter -p pe_postgresql_info.installed_server_version)"
3941
backup_dir="${backup_dir:-/opt/puppetlabs/server/data/postgresql/$pg_version/backups}"
@@ -64,7 +66,6 @@ for db in "${databases[@]}"; do
6466
rm -f -- "${backups[@]:0:$offset}"
6567
fi
6668

67-
6869
echo "Starting dump of database: $db"
6970

7071
if [[ $db == 'pe-classifier' ]]; then

files/vacuum_full_tables.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
usage() {
44
cat <<EOF
5-
echo "usage: $0 <table>"
6-
where <table> is one of: facts catalogs other
5+
echo "usage: $0 <table set> [sleep duration]"
6+
where <table set> is one of: facts catalogs other
7+
and [sleep duration] is an optional integer of seconds to sleep. Defaults to 300
78
EOF
89
exit 1
910
}
@@ -12,7 +13,6 @@ EOF
1213

1314
sleep_duration="${2:-300}"
1415

15-
# TODO: Is this used in PE 2018 and newer? RE: fact_values
1616
case "$1" in
1717
'facts')
1818
vacuum_tables=("'facts'" "'factsets'" "'fact_paths'" "'fact_values'")

0 commit comments

Comments
 (0)