Skip to content

Instantly share code, notes, and snippets.

@hari4274
Last active March 29, 2019 15:16
Show Gist options
  • Save hari4274/990de5a81deeb59daf2ba49553b37c79 to your computer and use it in GitHub Desktop.
Save hari4274/990de5a81deeb59daf2ba49553b37c79 to your computer and use it in GitHub Desktop.
ODOO Database and File store Backup Script using pgdump
#bin/bash
DBNAME='odoo10_sample'
DATETIME=$(date +"%Y%m%d%H%M%S")
DBFILENAME=${DBNAME}_${DATETIME}
HOMEDIR=`echo $HOME`
MANAGEDIR='/tmp' # Here i am using tmp folder for test
BACKUPDIR=$MANAGEDIR'/DBBACKUP'
FILESTORE_PATH=$HOMEDIR'/.local/share/Odoo/filestore/'
if [ ! -d "$BACKUPDIR" ]; then
# Control will enter here if $BACKUPDIR doesn't exist.
mkdir $BACKUPDIR
fi
if [ "$(stat -c '%a' $BACKUPDIR)" != "777" ]; then
# Control will enter here if $BACKUPDIR exist change permission.
sudo chmod 777 $BACKUPDIR
fi
sudo su postgres -c "pg_dump ${DBNAME} | gzip -c > ${BACKUPDIR}'/'${DBFILENAME}.dump.out.gz"
cd $FILESTORE_PATH && tar -zcf $BACKUPDIR'/'$DBFILENAME'.tar.gz' $DBNAME'/' && cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment