Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Last active October 10, 2015 17:03
Show Gist options
  • Save stepankuzmin/c91d96c52fd477e13e72 to your computer and use it in GitHub Desktop.
Save stepankuzmin/c91d96c52fd477e13e72 to your computer and use it in GitHub Desktop.
#!/bin/bash
green=`tput setaf 2`
reset=`tput sgr0`
dt=`date '+%Y.%m.%d_%H-%M-%S'`
backup_path=$HOME/backup/$dt
db_backup=$backup_path/astrakhan_production.sql
uploads_backup=$backup_path/uploads.tar.bz2
mkdir -p $backup_path
pg_dump --no-owner --no-acl astrakhan_production -f $db_backup
tar cvjf $uploads_backup -C $HOME/repository/portal/shared/public uploads
echo $backup_path
echo "${green}[*] Done: $backup_path${reset}"
# delete all files older than week from now
find $HOME/backup -mtime +7 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment