@@ -17,12 +17,19 @@ echo "# Configuring the GraphDB backup cron job #"
17
17
echo " #################################################"
18
18
19
19
if [ ${deploy_backup} == " true" ]; then
20
- GRAPHDB_ADMIN_PASSWORD=" $( aws --cli-connect-timeout 300 ssm get-parameter --region ${region} --name " /${name} /graphdb/admin_password" --with-decryption | jq -r .Parameter.Value | base64 -d) "
20
+ # Create the backup user. ID : 1010
21
+ echo " Creating the backup user"
22
+ useradd -r -M -s /usr/sbin/nologin gdb-backup
23
+ # Initialize the log file so that we are safe from potential attacks
24
+ [[ -f /var/opt/graphdb/node/graphdb_backup.log ]] && rm /var/opt/graphdb/node/graphdb_backup.log
25
+ touch /var/opt/graphdb/node/graphdb_backup.log
26
+ chown gdb-backup:gdb-backup /var/opt/graphdb/node/graphdb_backup.log
27
+ chmod og-rw /var/opt/graphdb/node/graphdb_backup.log
21
28
cat << -EOF >/usr/bin/graphdb_backup
22
29
#!/bin/bash
23
30
24
31
set -euo pipefail
25
- GRAPHDB_ADMIN_PASSWORD="\$ 1 "
32
+ GRAPHDB_ADMIN_PASSWORD="\$ (aws --cli-connect-timeout 300 ssm get-parameter --region ${region} --name "/ ${name} /graphdb/admin_password" --with-decryption | jq -r .Parameter.Value | base64 -d) "
26
33
NODE_STATE="\$ (curl --silent -u "admin:\$ GRAPHDB_ADMIN_PASSWORD" http://localhost:7201/rest/cluster/node/status | jq -r .nodeState)"
27
34
28
35
function trigger_backup {
83
90
EOF
84
91
85
92
chmod +x /usr/bin/graphdb_backup
86
- echo " ${backup_schedule} graphdb /usr/bin/graphdb_backup $GRAPHDB_ADMIN_PASSWORD " > /etc/cron.d/graphdb_backup
93
+ echo " ${backup_schedule} gdb-backup /usr/bin/graphdb_backup" > /etc/cron.d/graphdb_backup
87
94
chmod og-rwx /etc/cron.d/graphdb_backup
88
-
95
+ # Set ownership of aws-cli to backup user
96
+ chown -R gdb-backup:gdb-backup /usr/local/aws-cli
97
+ chmod -R og-rwx /usr/local/aws-cli/
89
98
log_with_timestamp " Cron job created"
90
99
else
91
100
log_with_timestamp " Backup module is not deployed, skipping provisioning..."
0 commit comments