diff --git a/appspec.yml b/appspec.yml index 735fba6e4..37c70a455 100644 --- a/appspec.yml +++ b/appspec.yml @@ -33,6 +33,11 @@ permissions: - file hooks: + BeforeInstall: + - location: scripts/backup.sh + timeout: 60 + runas: ec2-user + ApplicationStop: - location: scripts/stop.sh timeout: 60 @@ -42,3 +47,8 @@ hooks: - location: scripts/deploy.sh timeout: 600 runas: ec2-user + + AfterInstall: + - location: scripts/restore.sh + timeout: 60 + runas: ec2-user diff --git a/scripts/backup.sh b/scripts/backup.sh new file mode 100644 index 000000000..143a569eb --- /dev/null +++ b/scripts/backup.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir -p /home/ec2-user/cicd/backup +cp /home/ec2-user/cicd/src/main/resources/application-prod.yml /home/ec2-user/cicd/backup/ diff --git a/scripts/restore.sh b/scripts/restore.sh new file mode 100644 index 000000000..3e6652a8f --- /dev/null +++ b/scripts/restore.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [ -f /home/ec2-user/cicd/backup/application-prod.yml ]; then + cp /home/ec2-user/cicd/backup/application-prod.yml /home/ec2-user/cicd/src/main/resources/application-prod.yml +fi