dotfiles

config files and scripts at HOME.
git clone git://git.ricketyspace.net/dotfiles.git
Log | Files | Refs

commit b6148eddabb7f1a7d71b8febe7d54d7e1762498d
parent eab2c7467dadb2f6114f0bcb9d5a17bcedf316c5
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu, 24 May 2018 22:25:09 +0000

.bin: Remove pgdump (Moved to dip).

Diffstat:
.bin/pgdump | 92-------------------------------------------------------------------------------
1 file changed, 0 insertions(+), 92 deletions(-)

diff --git a/.bin/pgdump b/.bin/pgdump @@ -1,92 +0,0 @@ -#!/usr/bin/env zsh -# -# Copyright © 2017 rsiddharth <s@ricketyspace.net> -# -# License: GPL-3.0-or-later -# -# Backup postgres databases. - -setopt shwordsplit - -dbs_file() -{ - DBS_FILE=$HOME'/.pg-dump-dbs' - - if [ ! -r $DBS_FILE ]; then - echo 'Error: ' $DBS_FILE 'not found' - exit 1 - fi -} - -dbs() -{ - DBS=$(cat $DBS_FILE) - - if [ -z "$DBS" ]; then - echo 'No databases to dump exiting' - exit 0 - fi -} - -init_user() -{ - if [ ! -z $1 ]; then - USER=$1 - fi - - if [ -z $USER ]; then - echo 'Error: USER not set' - exit 1 - fi -} - -init_dumps_dir() -{ - if [ ! -z $1 ]; then - PGDUMPS_DIR=$1 - fi - - if [ -z $PGDUMPS_DIR ]; then - echo 'Error: PGDUMPS_DIR not set' - exit 1 - fi - - # Create dumps directory if not already created. - if [ ! -d $PGDUMPS_DIR ]; then - echo 'Creating pgdumps directory ' $PGDUMPS_DIR - mkdir -p $PGDUMPS_DIR - fi - -} - -bu_dump_dir() -{ - BU_DIR=$1'.'`date +%s` - echo 'Backing up existing dump directory' $1 'to' $BU_DIR - mv $1 $BU_DIR -} - -init_dump_dir() -{ - export DUMP_DIR=$PGDUMPS_DIR'/dump-'$1 - - # If it already exists; backup it up. - if [ -d $DUMP_DIR ]; then - bu_dump_dir $DUMP_DIR - fi -} - -dump_db () -{ - pg_dump -U $USER -cC -Fd -d $1 -f $DUMP_DIR -} - -# init. stuff. -dbs_file && dbs && init_user $1 && init_dumps_dir $2 - -# do the dumps. -for db in $DBS; do - init_dump_dir $db \ - && echo 'Dumping' $db'... at' $DUMP_DIR \ - && dump_db $db -done