Skip to content

christianoviedo/chbackup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 

Repository files navigation

ChBackup

Linux rsync incremental backup of mysql and postgresql databases and local files in an external repository. It also can backup dokku repositories and databases. Default daily and weekly backups.

Prerequisites

All files must be installed in servers which contains files to be copied. The processes work with cron, you can adjust the time if you want. The connection between servers must be done with ssh public key auth. Connection with remote server MUST be done with ssh public/private key.

For postgresql backup you need to give access to replicate and access for user postgres, like this

local   all             postgres        trust
local   replication     postgres        trust

Installing

  1. Copy etc files to your server. After you must have the following structure:
/etc/cron.daily/backup_daily
/etc/cron.weekly/backup.weekly
/etc/chbackup/backup.conf
/etc/chbackup/exclude-list.conf
/etc/logrotate.d/backup-log
  1. Edit backup.conf file
USER=<user name in backup server>
SERVER=<IP or server name>
SERVER_DIR=<Remote directory to store files (for multiple servers)>
LOCAL_DIR=<Local directories to backup separated by :>
DO_MYSQL_BACKUP=1 # do mysql backup?
DO_PGSQL_BACKUP=0 # do postgresql backup?
DO_DOKKU_DB_BACKUP=0 # do dokku db backup?
LOGFILE=/var/log/backup.log
TOT_BKP=3 # amount of historic backups to keep on remote server
DELETE_MISSING=1 # remove locally deleted files from backup server

These are the recommnendations for setting the LOCAL_DIR var:

  • If VESTA of LARAVEL FORGE: /home
  • If DOKKU: /home/dokku:/var/lib/dokk
  • If CAPROVER: /srv:/captain:/var/lib/docker/volumes

Also if using Dokku databases don't forget to set DO_DOKKU_DB_BACKUP=1

  1. If mysql backup edit mysql.conf with local user/pass [client] user= password=

  2. Assign execution permissions to backup scripts and test

shell# chmod 755 /etc/cron.daily/backup_daily
shell# chmod 755 /etc/cron.weekly/backup.weekly
shell# /etc/cron.daily/backup_daily
  1. Check log file
shell# tail -f /var/log/backup.log
  1. BD permissions BD must have permissions for full reading
grant select, lock tables, event, show view, process on *.* to backup@localhost;

About

Linux Rsync backup of files and mysql databases

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages