1
0
mirror of https://github.com/deajan/obackup.git synced 2024-11-15 04:03:41 +01:00
obackup/README.md

84 lines
4.7 KiB
Markdown
Raw Normal View History

2013-06-12 19:55:16 +02:00
obackup
=======
2016-08-06 13:45:41 +02:00
A robust file & database backup script that works for local and remote push or pull backups via ssh.
2013-06-12 20:25:25 +02:00
2013-06-12 21:08:07 +02:00
## About
2016-08-06 13:45:41 +02:00
obackup is designed to make the backup process as reliable as possible.
2013-06-12 20:25:25 +02:00
It divides the whole backup process into tasks, allowing each task to execute for a certain amount of time.
2013-11-02 18:55:17 +01:00
If a task doesn't finish in time, it's stopped and the next task in list is processed.
2013-06-12 20:25:25 +02:00
Before a task gets stopped, a first warning message is generated telling the task takes too long.
2013-11-02 18:55:17 +01:00
Every action gets logged, and if a warning has been generated, a task gets stopped or an error happens, an alert email will be sent.
2013-06-12 21:08:07 +02:00
Remote backups are initiated from the backup server instead of the production server, so hacked servers won't get ssh access to the backup server.
2016-08-06 13:45:41 +02:00
obackup can enumerate and backup all MariaDB / MySQL databases present on a server.
2013-06-13 08:24:25 +02:00
It can also enumarate all subdirectories of a given path and process them as separate tasks (usefull for multiple vhosts).
2013-11-02 18:55:17 +01:00
It will do several checks before launching a backup like execution checks, dryruns, checking backup size and available local disk space.
2013-06-12 21:08:07 +02:00
2016-08-06 13:45:41 +02:00
obackup can execute local and remote commands before and after backup execution,
2013-11-02 18:55:17 +01:00
thus providing an easy way to handle snapshots (see https://github.com/deajan/zsnap for a zfs snapshot management script).
It may also rotate backups for you.
2013-06-16 14:11:30 +02:00
2016-08-06 13:45:41 +02:00
As of today, obackup has been tested successfully on RHEL / CentOS 5, 6 and 7, Debian 6 and 7, Linux Mint 14 and 17, FreeBSD 8.3 and 10.3.
Currently, obackup also runs on MacOSX and Windows MSYS environment.
2013-06-12 21:08:07 +02:00
2014-11-28 13:15:49 +01:00
## Warning
Obackup now follows symlinks and treats them as the referent files / dirs, following symlinks even outside the backup root, which IMHO is more secure in terms of backups.
You may disable this behavior in the config file.
2013-06-12 21:08:07 +02:00
## Installation
You can download the latest obackup script from authors website.
2013-11-02 18:55:17 +01:00
You may also clone the following git which will maybe have some more recent builds.
2013-06-12 21:08:07 +02:00
2016-08-06 13:45:41 +02:00
$ git clone -b "v2.0" git://github.com/deajan/obackup.git
$ cd obackup
$ ./install.sh
2013-10-12 19:12:15 +02:00
2016-08-06 13:45:41 +02:00
obackup needs to run with bash shell, using any other shell will most probably fail.
2013-11-02 18:55:17 +01:00
Once you have grabbed a copy, just edit the config file with your favorite text editor to setup your environment and you're ready to run.
A detailled documentation can be found on the author's site.
You can run multiple instances of obackup scripts with different backup environments. Just create another configuration file,
edit it's environment and you're ready to run concurrently.
2013-06-12 21:08:07 +02:00
2013-06-15 14:55:50 +02:00
Performing remote backups requires you to create RSA private / public key pair. Please see documentation for further information.
Performing mysql backups requires to create a mysql user with SELECT rights on all databases. Please see documentation for further information.
2013-11-02 18:55:17 +01:00
Performing backup with SUDO_EXEC option requires to configure sudoers file to allow some commands without password.
Keep in mind that running backup as superuser might be a security risk. You should generally prefer a read only enabled user.
Please see documentation for further information.
2013-06-15 14:55:50 +02:00
2013-06-13 19:14:21 +02:00
## Usage
MariaDB / MySQL backups are consistent because dumps are done with the --single-transaction option.
2013-11-02 18:55:17 +01:00
File backups can be done directly if data won't change while a backup is going on (generally true on vhosts),
but backing up a snapshot of the actual data is preferable as it will stay consistent. LVM, zfs or btrfs snapshots will do fine.
2013-06-13 19:14:21 +02:00
2013-11-02 18:55:17 +01:00
You may try your setup by specifying the "--dry" parameter which will run a simulation of what will be done. Specifying "--verbose" will also list any command
that's actually launched and it's result.
2013-06-13 19:14:21 +02:00
2013-06-16 14:27:45 +02:00
$ ./obackup.sh path/to/backup.conf --dry
$ ./obackup.sh path/to/backup.conf
2013-11-02 18:55:17 +01:00
$ ./obackup.sh path/to/backup.conf --silent
2013-06-13 19:14:21 +02:00
One you're happy with a test run, you may run obackup as a cron task with the "--silent" parameter so output will not be written to stdout.
2013-11-02 18:55:17 +01:00
All backup activity is logged to "/var/log/obackup_backupname.log" or current directory if /var/log is not writable.
2013-06-13 19:14:21 +02:00
2014-11-28 13:20:21 +01:00
You may mix "--silent" and "--verbose" parameters to output verbose input only in the log files.
## Final words
2013-06-13 19:14:21 +02:00
2013-11-02 18:55:17 +01:00
Backup tasks aren't always reliable, connectivity loss, insufficient disk space, hacked servers with tons of unusefull stuff to backup... Anything can happen.
2016-08-06 13:45:41 +02:00
obackup will sent your a warning email for every issue it can handle.
2013-11-02 18:55:17 +01:00
Nevertheless, you should assure yourself that your backup tasks will get done the way you meant it. Also, a backup isn't valuable until you're sure
you can successfully restore. Try to restore your backups to check whether everything is okay. Backups will keep file permissions and owners,
but may loose ACLs if destination file system won't handle them.
2013-06-13 19:14:21 +02:00
2013-06-12 21:08:07 +02:00
## Author
2013-11-02 18:55:17 +01:00
Feel free to mail me for limited support in my free time :)
2016-08-06 13:45:41 +02:00
Orsiris de Jong | ozy@netpower.fr