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.


TODAYS_DATE=`date +"%m-%d-%Y"`

ssh -i /home/user/.ssh/data-manager_rsa 'docker exec user-db mysqldump -u db_user --password=supersecretpassword photo_blog' > /home/user/backups/${TODAYS_DATE}_db_dump.sql

ssh -i /home/user/.ssh/data-manager_rsa '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 /home/user/backups/${TODAYS_DATE}_media.tar

I don't love having the database password in …