Created
December 31, 2023 14:29
-
-
Save lol97/0f6e5c3c69e69a1c36f54ebc83fcec81 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| #filename backup | |
| fileName= db_retail_bck_$(date +%Y%m%d).log | |
| path='/home/user/backup' | |
| fullPath=${path}/${fileName} | |
| echo ${fileName} | |
| echo ${path} | |
| echo ${fullPath} | |
| #dobackup | |
| if ! test -f ${fullPath}; then | |
| mysqldump --no-tablespaces -u retail2 -p'Retail@--20@' db_toko > ${fullPath} | |
| fi | |
| #if exist and backup success delete file older than 7 days | |
| if test -f ${fullPath}; then | |
| find ${path} ! -type d -mtime +7 -name 'db_retail_bck_*.sql' -delete | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment