From bf32201d4d9fa1f9b99a9eb21e4ac4f1a45c9c60 Mon Sep 17 00:00:00 2001 From: YeaChan05 Date: Wed, 19 Jun 2024 20:02:16 +0900 Subject: [PATCH] =?UTF-8?q?[ci]=20=EC=84=A4=EC=A0=95=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=B0=B1=EC=97=85=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 설정파일 백업 로직 작성 --- appspec.yml | 10 ++++++++++ scripts/backup.sh | 4 ++++ scripts/restore.sh | 5 +++++ 3 files changed, 19 insertions(+) create mode 100644 scripts/backup.sh create mode 100644 scripts/restore.sh 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