Skip to content

Instantly share code, notes, and snippets.

@stas-dovgodko
Last active September 1, 2023 15:03
Show Gist options
  • Save stas-dovgodko/0b2861b3cbd08e8ca2b171f959a1dae5 to your computer and use it in GitHub Desktop.
Save stas-dovgodko/0b2861b3cbd08e8ca2b171f959a1dae5 to your computer and use it in GitHub Desktop.
Backup php craft cms to aws s3 and glacier
#!/bin/bash
mydir="$(dirname "$(readlink -f "$0")")"
php ${mydir}/craft backup --interactive=0
backupfile="$(ls -Art "${mydir}/storage/backups/" | tail -n 1)"
now=`date +"%Y-%m-%d"`
tar cvzf ${mydir}/storage/runtime/temp/backup-${now}.tar.gz ${mydir}/storage/backups/${backupfile} ${mydir}/web/uploads/*
aws glacier upload-archive --account-id - --vault-name backups --body ${mydir}/storage/runtime/temp/backup-${now}.tar.gz
aws s3 cp ${mydir}/storage/runtime/temp/backup-${now}.tar.gz s3://myfancysitebacket-backups/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment