Saturday, 7 January 2017

Dokumentasi : Backup & Restore

Status : Draft

Disini kita ingin melakukan backup database dan folder upload setiap hari pada pukul 12 siang. 

Buat script backup di ~/bin/backup.sh

#!/bin/bash

hari=$(date +"%A")

pg_dump -Fp -U banksoalsbmptn banksoalsbmptn -h 127.0.0.1 >  /backup/banksoalsbmptn/postgresql/$hari.sql

mkdir -p /backup/banksoalsbmptn/webapps/upload/$hari

cp -rf /opt/www/banksoalsbmptn/application/webroot/upload /backup/banksoalsbmptn/webapps/upload/$hari

Buat entri cron :

$crontab  -e

# m h  dom mon dow   command
* 12 * * 1 /home/openthinklabs/bin/backup.sh
* 12 * * 2 /home/openthinklabs/bin/backup.sh
* 12 * * 3 /home/openthinklabs/bin/backup.sh
* 12 * * 4 /home/openthinklabs/bin/backup.sh
* 12 * * 5 /home/openthinklabs/bin/backup.sh
* 12 * * 6 /home/openthinklabs/bin/backup.sh

No comments:

Post a Comment