Blog
Where the blog posts hang out.
Backing Up Django Data in Docker-Compose Environment
My solution for backing up this website's data
I chose to create a simple bash script that runs on a VM on my home network and backups up the database and media files used on this website.
#!/bin/bash
TODAYS_DATE=`date +"%m-%d-%Y"`
ssh -i /home/user/.ssh/data-manager_rsa user@averyuslaner.com 'docker exec user-db mysqldump -u db_user --password=supersecretpassword photo_blog' > /home/user/backups/averyuslaner.com/${TODAYS_DATE}_db_dump.sql
ssh -i /home/user/.ssh/data-manager_rsa user@averyuslaner.com 'docker run --rm -v personal_website_media_volume:/media -v $(pwd)/backups:/backups ubuntu tar cvf /backups/media.tar /media'
scp -i /home/user/.ssh/data-manager_rsa user@averyuslaner.com:/home/user/backups/media.tar /home/user/backups/averyuslaner.com/${TODAYS_DATE}_media.tar
I don't love having the database password in …