Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
063f5c09
Commit
063f5c09
authored
May 06, 2016
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preserve older versions of go-server backups.
parent
3ddfaa35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
11 deletions
+34
-11
playbooks/roles/go-server/defaults/main.yml
+9
-2
playbooks/roles/go-server/tasks/main.yml
+2
-3
playbooks/roles/go-server/templates/gocd_backup.j2
+23
-6
No files found.
playbooks/roles/go-server/defaults/main.yml
View file @
063f5c09
...
...
@@ -64,17 +64,24 @@ GO_SERVER_H2DB_BACKUP_PATH: "artifacts/db_backup/"
GO_SERVER_H2DB_BACKUP_LOCATION
:
"
{{
GO_SERVER_HOME
}}/{{
GO_SERVER_H2DB_BACKUP_PATH
}}/{{
GO_SERVER_H2DB_NAME
}}"
# For use in backup/restore of a GoCD configuration.
GO_SERVER_BACKUP_ENVIRONMENT
:
"
sandbox"
GO_SERVER_BACKUP_SNITCH_URL
:
"
https://nosnch.in/4444444444"
GO_SERVER_BACKUP_FILENAME
:
"
go-server-latest-backup.tgz"
GO_SERVER_TEMP_RESTORE_DIRECTORY
:
"
/tmp/go-server-backup"
GO_SERVER_BACKUP_S3_BUCKET
:
"
edx-
tools
-gocd-backup"
GO_SERVER_BACKUP_S3_BUCKET
:
"
edx-
{{
GO_SERVER_BACKUP_ENVIRONMENT
}}
-gocd-backup"
GO_SERVER_BACKUP_S3_OBJECT
:
"
{{
GO_SERVER_BACKUP_FILENAME
}}"
GO_SERVER_BACKUP_SNITCH_URL
:
"
https://nosnch.in/4444444444"
GO_SERVER_BACKUP_APT_PKGS
:
[
"
python-pip"
,
"
jq"
]
GO_SERVER_BACKUP_PIP_PKGS
:
[
"
boto"
,
"
awscli"
]
GO_SERVER_BACKUP_API_URL
:
"
http://localhost:8153/go/api/backups"
GO_SERVER_BACKUP_TMP_LOCATION
:
"
/tmp/{{
GO_SERVER_BACKUP_FILENAME
}}"
GO_SERVER_BACKUP_CRON_SCRIPT_LOCATION
:
"
/root/gocd_backup.sh"
# When "true", attempts to restore go-server backup from S3.
GO_SERVER_RESTORE_BACKUP
:
"
false"
# When "true", attempts to configure regular, cron-based backups to S3 on go-server.
GO_SERVER_CONFIGURE_BACKUPS
:
"
false"
# password file setup
GO_SERVER_PASSWORD_FILE_NAME
:
"
password.txt"
GO_SERVER_ADMIN_USERS
:
[
"
admin"
]
...
...
playbooks/roles/go-server/tasks/main.yml
View file @
063f5c09
...
...
@@ -103,9 +103,8 @@
group
:
"
{{
GO_SERVER_GROUP
}}"
force
:
no
# If a GoCD restore file is specified, attempt to download and restore it.
-
include
:
download_backup.yml
when
:
GO_SERVER_BACKUP_S3_BUCKET and GO_SERVER_BACKUP_S3_OBJECT
when
:
GO_SERVER_BACKUP_S3_BUCKET and GO_SERVER_BACKUP_S3_OBJECT
and GO_SERVER_RESTORE_BACKUP == "true"
-
name
:
replace the admin line in the password file post-restore
lineinfile
:
...
...
@@ -127,4 +126,4 @@
state
:
restarted
-
include
:
setup_regular_backup.yml
when
:
GO_SERVER_BACKUP_S3_BUCKET and GO_SERVER_BACKUP_S3_OBJECT
when
:
GO_SERVER_BACKUP_S3_BUCKET and GO_SERVER_BACKUP_S3_OBJECT
and GO_SERVER_CONFIGURE_BACKUPS == "true"
playbooks/roles/go-server/templates/gocd_backup.j2
View file @
063f5c09
...
...
@@ -7,6 +7,7 @@ gocd_password="{{ GO_SERVER_BACKUP_PASSWORD }}"
gocd_backup_location
=
"{{ GO_SERVER_BACKUP_TMP_LOCATION }}"
s3_backup_bucket
=
"{{ GO_SERVER_BACKUP_S3_BUCKET }}"
snitch_url
=
"{{ GO_SERVER_BACKUP_SNITCH_URL }}"
gocd_backup_base
=
gocd-
"{{ GO_SERVER_BACKUP_ENVIRONMENT }}"
# Trigger the backup and capture the backup path.
# The output of the api call is documented here:
...
...
@@ -52,22 +53,37 @@ null)
;;
esac
# Make backup into a tarball.
tar
zcvf
"
$gocd_backup_location
"
-C
"
$(
dirname
"
$backup_path
"
)
"
"
$(
basename
"
$backup_path
"
)
"
# Make latest backup into a tarball.
backup_dir_name
=
"
$(
basename
"
$backup_path
"
)
"
tar
zcvf
"
$gocd_backup_location
"
-C
"
$(
dirname
"
$backup_path
"
)
"
"
${
backup_dir_name
}
"
# Transfer tarball to S3.
aws_output
=
$(
aws s3 cp
"
$gocd_backup_location
"
"s3://
$s3_backup_bucket
"
2>&1
)
dated_backup_filename
=
"
${
gocd_backup_base
}
-
${
backup_dir_name
}
.tgz"
# Transfer tarball to S3 with datetime'd filename.
aws_output
=
$(
aws s3 cp
"
${
gocd_backup_location
}
"
"s3://
${
s3_backup_bucket
}
/
${
dated_backup_filename
}
"
2>&1
)
case
$aws_output
in
*
failed
*
)
echo
"Backup transfer failed:
$aws_output
"
exit
;;
*
)
echo
"Backup transfer of
${
dated_backup_filename
}
to S3 bucket
$s3_backup_bucket
succeeded."
;;
esac
# Transfer tarball to S3 with official backup filename.
aws_output
=
$(
aws s3 cp
"
${
gocd_backup_location
}
"
"s3://
${
s3_backup_bucket
}
"
2>&1
)
case
$aws_output
in
*
failed
*
)
echo
"Backup transfer failed:
$aws_output
"
exit
;;
*
)
echo
"Backup transfer to S3 bucket
$s3_backup_bucket
succeeded."
echo
"Backup transfer
of
$(
basename
"
${
gocd_backup_location
}
"
)
to S3 bucket
$s3_backup_bucket
succeeded."
# Report to Dead Man's Snitch.
curl
$snitch_url
;;
esac
# Remove the tarball.
rm
-f
"
$gocd_backup_location
"
rm
-f
"
$gocd_backup_location
"
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment