Skip to content

Instantly share code, notes, and snippets.

View waqasisme's full-sized avatar

Muhammad Waqas waqasisme

  • Düsseldorf, Germany
View GitHub Profile
@waqasisme
waqasisme / database-backup.sh
Last active June 30, 2022 09:50
DB backup gist (daily for current month, monthly for current year, delete backups older than a year)
#!/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")"
@waqasisme
waqasisme / logger.js
Created May 3, 2018 18:06
Basic winstonjs logger setup
// 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');
/**