Backup script ------------- Backup script consists of 3 parts. 1) Source backuper.sh 2) Backup definition 3) Run command "backup" Available commands for backup definition ---------------------------------------- name - mandatory parametr; one word name of backup cmd - command that is subject of backup; e.g. pg_dumpall places - string list of places for tar exclude - list of places that tar ignores generate - command that grants access to backup; e.g. sudo remote - run backup command at different server run - run command before backup; see examples store_file - the result of backup should be stored in file store - specify command that stores backup after - run command after successful backup (hook) result_file - get full path to file with backup file_type - (optionally) specify file type of backup; only with command backup (e.g. .sql for DB dumps) Configuration ------------- Backuper expects configuration file in $HOME/.backuper.sh.conf In configuration file is possible to specify there variables: MBUFFER_SIZE - the size of each buffer (mbuffer utility) GPG_RECIPIENTS - the list of GPG recipients of encrypted backup Backup script example: ------------------------ #!/bin/sh . backuper.sh name "postgres" remote "ssh srv" generate "sudo -u postgres" file_type "sql" # Optional cmd "pg_dumpall" store_file "/mnt/data/backups" backup ----- End of example script ----- Examples of different backup definitions ---------------------------------------- (Without "name" parameter and "backup" command.) 1) Backup all files from srv; exclude /proc, /sys/ and /dev and store it in file in /mnt/data folder: remote "ssh srv" places "/" exclude "/proc" "/sys" "/dev" store_file "/mnt/data" 2) Backup some files from local computer and send it to srv (ssh force-command take care about rest): places "/etc /home" store "ssh srv" 3) The same as 2; root is needed: places "/etc /home /root" generate "sudo" store "ssh srv" 4) Run some important command before backup (on remote machine): remote "ssh root@srv" places "/" exclude "/proc" "/sys" "/dev" run "dpkg --get-selections > /tmp/list_of_packages" store_file "/mnt/data" 5) Run hook after successful backup places "/etc /home /root" store_file "/mnt/data" after "cp $(result_file) /mnt/nas/backups/."