Commit 742bbe44 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

feat(ci): weekly backup

parent 59a13abd
# In case something goes horribly wrong, you can fall back to `image: ruby:latest` # In case something goes horribly wrong, you can fall back to `image: ruby:latest`
image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.0 image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.0
stages:
- build
- deploy
- backup
build the website: build the website:
stage: build stage: build
before_script: before_script:
...@@ -34,3 +39,20 @@ Deploy to production: ...@@ -34,3 +39,20 @@ Deploy to production:
- ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/web/r3lab_$CI_JOB_ID" - ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/web/r3lab_$CI_JOB_ID"
- scp -P $SSHPORT -r build/* $SSHCONNECT:~/web/r3lab_$CI_JOB_ID - scp -P $SSHPORT -r build/* $SSHCONNECT:~/web/r3lab_$CI_JOB_ID
- ssh -p $SSHPORT $SSHCONNECT "cd ~/web/latest && ln -fs ../r3lab_$CI_JOB_ID/* . && cd .. && find . -type d -name 'r3lab*' -not -newermt '-1 minutes' -exec rm -rf {} +" - ssh -p $SSHPORT $SSHCONNECT "cd ~/web/latest && ln -fs ../r3lab_$CI_JOB_ID/* . && cd .. && find . -type d -name 'r3lab*' -not -newermt '-1 minutes' -exec rm -rf {} +"
## Backups
Create the backup:
stage: backup
image: alpine:3.1
when: manual
before_script:
- 'which ssh-agent || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSHPRIVKEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- echo "$KNOWNHOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/web/latest ~/backups/; cd ~/web/; tar -zchvf ~/backups/backup_$(date +'%Y_%m_%d').tar.gz latest"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment