.github/workflows/backup_rolling.yml #716
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * *' # every day at midnight | |
jobs: | |
backup_rolling: | |
runs-on: ubuntu-latest | |
environment: backup | |
strategy: | |
matrix: | |
repository: [infrastructure, processing-sentinel-1, processing-sentinel-2, processing-sentinel-3, production-common, reference-system-documentation, reference-system-software, rs-config, rs-issues, user-web-client, website] | |
steps: | |
- name: Set up S3cmd cli tool | |
uses: s3-actions/s3cmd@v1.1 | |
with: | |
access_key: ${{ secrets.ACCESS_KEY_ID }} | |
secret_key: ${{ secrets.SECRET_ACCESS_KEY }} | |
- name: Interact with object storage | |
run: | | |
LIST2DELDAILY=$(s3cmd --host=${{ secrets.HOST_BASE }} --host-bucket=${{ secrets.HOST_BUCKET }} ls s3://csc-rs-backup/COPRS/${{ matrix.repository }}/ | grep DAILY | cut -d '/' -f 6 | sort | head -n -15) ; | |
for BACKUP in ${LIST2DELDAILY} ; do s3cmd --host=${{ secrets.HOST_BASE }} --host-bucket=${{ secrets.HOST_BUCKET }} rm -r s3://csc-rs-backup/COPRS/${{ matrix.repository }}/${BACKUP} ; done ; | |
LIST2DELMONTHLY=$(s3cmd --host=${{ secrets.HOST_BASE }} --host-bucket=${{ secrets.HOST_BUCKET }} ls s3://csc-rs-backup/COPRS/${{ matrix.repository }}/ | grep MONTHLY | cut -d '/' -f 6 | sort | head -n -2) ; | |
for BACKUP in ${LIST2DELMONTHLY} ; do s3cmd --host=${{ secrets.HOST_BASE }} --host-bucket=${{ secrets.HOST_BUCKET }} rm -r s3://csc-rs-backup/COPRS/${{ matrix.repository }}/${BACKUP} ; done ; |