Last active
March 29, 2019 15:16
-
-
Save hari4274/990de5a81deeb59daf2ba49553b37c79 to your computer and use it in GitHub Desktop.
ODOO Database and File store Backup Script using pgdump
This file contains hidden or 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/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