This file contains 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/sh | |
current_time=$(date "+%Y-%m-%d-%H-%M-%S") | |
backup_file_name=[FILENAME]-$current_time.sql | |
docker exec [DATABASE_CONTAINER_NAME] sh -c 'exec mysqldump --all-databases -u[USERNAME] -p[PASSWORD]' > /path/to/backups/$backup_file_name | |
# remove backups older than 1 year | |
find /path/to/backups/* -mtime +365 -delete | |
# remove daily backups for current month if today is the last day of the month | |
last_day="$(date -d "$(date +%Y-%m-01) +1 month -1 day" "+%d")" |
This file contains 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
// Libraries | |
const util = require('util'); | |
const winston = require('winston'); | |
const dailyRotater = require('winston-daily-rotate-file'); // for daily file rotating | |
const fs = require('fs'); | |
const path = require('path'); | |
const chalk = require('chalk'); // for colors | |
const moment = require('moment'); | |
/** |