This repository have some examples of shell scripts that create compressed backups of directories, MySQL and MongoDB databases.
It also contains scripts to send this backup files to AWS S3 and Digital Ocean Spaces.
These are the scripts:
dir_bkp.sh
: copy from an specific directorymongo_bkp.sh
: backup from an MongoDB databasesmongo_bkp_uri.sh
: same from above, but using the URI as a single parametermongo_bkp_uri_ssl.sh
: same from above, but with sslmysql-all_dbs-bkp.sh
: backup from MySQL databasesmysql-all_dbs-bkp-git.sh
: backup from MySQL databases and stores it in a git reposend_s3.sh
: send the files to an AWS S3 bucketsend_do_spaces.sh
: send the files to a Digital Ocean Space
All scripts receive almost all settings by parameters. I'll list some examples.
./dir_bkp.sh <BASENAME> <SOURCE_DIR> <STASH_DIR> <WORK_DIR>
- BASENAME: the basename of the file which will be used in the final filename
- SOURCE_DIR: the directory from which the backup will be created
- STASH_DIR: the directory where the backup will be placed
- WORK_DIR: the directory where the process will be executed
./mongo_bkp.sh <BASENAME> <MONGODB_HOST> <MONGODB_PORT> <MONGODB_USER> <MONGODB_PASS> <MONGODB_AUTH_DB> <STASH_DIR> <WORK_DIR>
- BASENAME: the basename of the file which will be used in the final filename
- MONGODB_HOST: the address of the MongoDB Server
- MONGODB_PORT: the port of the MongoDB Server
- MONGODB_USER: the user to access MongoDB Server
- MONGODB_PASS: the password to acess MongoDB Server
- MONGODB_AUTH_DB: the database which will be used to authenticate
- STASH_DIR: the directory where the backup will be placed
- WORK_DIR: the directory where the process will be executed
./mongo_bkp_uri.sh <BASENAME> <MONGODB_URI> <STASH_DIR> <WORK_DIR>
- BASENAME: the basename of the file which will be used in the final filename
- MONGODB_URI: the complete URI to connect to a MongoDB Server
- STASH_DIR: the directory where the backup will be placed
- WORK_DIR: the directory where the process will be executed
./mongo_bkp_uri_ssl.sh <BASENAME> <MONGODB_URI> <STASH_DIR> <WORK_DIR>
- BASENAME: the basename of the file which will be used in the final filename
- MONGODB_URI: the complete URI to connect to a MongoDB Server
- STASH_DIR: the directory where the backup will be placed
- WORK_DIR: the directory where the process will be executed
./mysql-all_dbs-bkp.sh <BASENAME> <DB_HOST> <DB_USER> <DB_PASS> <STASH_DIR> <WORK_DIR>
- BASENAME: the basename of the file which will be used in the final filename
- DB_HOST: the address of the MySQL Server
- DB_USER: the user to access MySQL Server
- DB_PASS: the password to acess MySQL Server
- STASH_DIR: the directory where the backup will be placed
- WORK_DIR: the directory where the process will be executed
./mysql-all_dbs-bkp.sh <BASENAME> <DB_HOST> <DB_USER> <DB_PASS> <GIT_DIR>
- BASENAME: the basename of the file which will be used in the final filename
- DB_HOST: the address of the MySQL Server
- DB_USER: the user to access MySQL Server
- DB_PASS: the password to acess MySQL Server
- GIT_DIR: the git directory where the backup will be placed
./send_s3.sh <STASH_DIR> <UPLOADED_DIR> <AWS_BUCKET> <AWS_REGION> <S3KEY> <S3SECRET>
- STASH_DIR: the directory where the stash files are
- UPLOADED_DIR: the directory where the files will be moved after upload
- AWS_BUCKET: the AWS S3 bucket name
- AWS_REGION: the AWS Region where the AWS S3 Bucket is located
- S3KEY: the AWS S3 Key
- S3SECRET: the AWS S3 Secret
./send_do_spaces.sh <STASH_DIR> <UPLOADED_DIR> <SPACE_NAME> <DO_REGION> <AUTH_KEY> <AUTH_SECRET>
- STASH_DIR: the directory where the stash files are
- UPLOADED_DIR: the directory where the files will be moved after upload
- SPACE_NAME: the Digital Ocean Space name
- DO_REGION: the Digital Ocean region where the Space is located
- AUTH_KEY: the auth key
- AUTH_SECRET: the auth secret