Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
interessen:computer:pc_technik:backup [2015/01/30 13:58] tomtom |
interessen:computer:pc_technik:backup [2015/02/15 11:54] (current) tomtom |
error_check() | error_check() |
{ | { |
IGNOR=`jq .error_hand.err_ignore $DATA_FILE|sed 's/\"//g'` | echo "job 'error_check' is running" |
| IGNOR=`jq .jobs.error_check.err_ignore $DATA_FILE|sed 's/\"//g'` |
echo "error to ignor : "$IGNOR | echo "error to ignor : "$IGNOR |
| |
HIGH=`jq .error_hand.err_high $DATA_FILE|sed 's/\"//g'` | HIGH=`jq .jobs.error_check.err_high $DATA_FILE|sed 's/\"//g'` |
MEDIUM=`jq .error_hand.err_medium $DATA_FILE|sed 's/\"//g'` | MEDIUM=`jq .jobs.error_check.err_medium $DATA_FILE|sed 's/\"//g'` |
LOW=`jq .error_hand.err_low $DATA_FILE|sed 's/\"//g'` | LOW=`jq .jobs.error_check.err_low $DATA_FILE|sed 's/\"//g'` |
| |
for FILE in `cat $LOG_CHECK_FILE | grep '<f'|cut -d\/ -f2-` | for FILE in `cat $LOG_CHECK_FILE | grep '<f'|cut -d\/ -f2-` |
fi | fi |
done | done |
messaging | |
} | } |
| |
messaging() | messaging() |
{ | { |
echo "generate message for syslog" | echo "job 'messaging' is running, generate massage for syslog" |
if [ $ERR_COUNT -gt 0 ] | if [ $ERR_COUNT -gt 0 ] |
then | then |
echo $DIR | echo $DIR |
echo "run : "$METHOD `jq .jobs.replicate.run_options $DATA_FILE|sed 's/\"//g'` $DIR $DESTIN $PASS_OPT | echo "run : "$METHOD `jq .jobs.replicate.run_options $DATA_FILE|sed 's/\"//g'` $DIR $DESTIN $PASS_OPT |
echo " " >> $LOG_FILE | |
echo "{"$DIR"()" >> $LOG_FILE | echo "{"$DIR"()" >> $LOG_FILE |
$METHOD `jq .jobs.replicate.run_options $DATA_FILE|sed 's/\"//g'` $DIR $DESTIN $PASS_OPT >> $LOG_FILE | $METHOD `jq .jobs.replicate.run_options $DATA_FILE|sed 's/\"//g'` $DIR $DESTIN $PASS_OPT >> $LOG_FILE |
echo " " >> $LOG_CHECK_FILE | |
echo "{"$DIR"()" >> $LOG_CHECK_FILE | echo "{"$DIR"()" >> $LOG_CHECK_FILE |
$METHOD `jq .jobs.replicate.log_options $DATA_FILE|sed 's/\"//g'` $DIR $DESTIN $PASS_OPT >> $LOG_CHECK_FILE | $METHOD `jq .jobs.replicate.log_options $DATA_FILE|sed 's/\"//g'` $DIR $DESTIN $PASS_OPT >> $LOG_CHECK_FILE |
date >> $LOG_FILE | date >> $LOG_FILE |
date >> $LOG_CHECK_FILE | date >> $LOG_CHECK_FILE |
| error_check |
else | else |
(($ERR_STOP++)) | (($ERR_STOP++)) |
{ | { |
echo "job 'mount_fs' is running" | echo "job 'mount_fs' is running" |
# check if target host available | # check if target host available |
TARGET_SRV=`jq .jobs.mount_fs.ping_target $DATA_FILE|sed 's/\"//g'` | TARGET_SRV=`jq .jobs.mount_fs.ping_target $DATA_FILE|sed 's/\"//g'` |
echo "check, if you'r in right location, try to ping "$TARGET_SRV | echo "check, if you'r in right location, try to ping "$TARGET_SRV |
MOUNT_P=`jq .jobs.mount_fs.mount_point $DATA_FILE|sed 's/\"//g'` | MOUNT_P=`jq .jobs.mount_fs.mount_point $DATA_FILE|sed 's/\"//g'` |
if( ping -c 3 $TARGET_SRV > /dev/null ) | if( ping -c 3 $TARGET_SRV > /dev/null ) |
then | then |
echo $TARGET_SRV" reachable, you'r in right location to backup" | echo $TARGET_SRV" reachable, you'r in right location to backup" |
if [[ `jq .jobs.mount_fs.mount_def $DATA_FILE|sed 's/\"//g'` = "file" ]] | if [[ `jq .jobs.mount_fs.mount_def $DATA_FILE|sed 's/\"//g'` = "file" ]] |
then | then |
echo "mount "`jq .jobs.mount_fs.mount_opt $DATA_FILE|sed 's/\"//g'` `jq .jobs.mount_fs.mount_file $DATA_FILE|sed 's/\"//g'` $MOUNT_P | echo "mount "`jq .jobs.mount_fs.mount_opt $DATA_FILE|sed 's/\"//g'` `jq .jobs.mount_fs.mount_file $DATA_FILE|sed 's/\"//g'` $MOUNT_P |
mount `jq .jobs.mount_fs.mount_opt $DATA_FILE|sed 's/\"//g'` `jq .jobs.mount_fs.mount_file $DATA_FILE|sed 's/\"//g'` $MOUNT_P | mount `jq .jobs.mount_fs.mount_opt $DATA_FILE|sed 's/\"//g'` `jq .jobs.mount_fs.mount_file $DATA_FILE|sed 's/\"//g'` $MOUNT_P |
else | else |
CONNECT=`jq .jobs.mount_fs.mount_srv $DATA_FILE|sed 's/\"//g'`:`jq .jobs.mount_fs.mount_share $DATA_FILE|sed 's/\"//g'` | CONNECT=`jq .jobs.mount_fs.mount_srv $DATA_FILE|sed 's/\"//g'`:`jq .jobs.mount_fs.mount_share $DATA_FILE|sed 's/\"//g'` |
logger $message | logger $message |
} | } |
| |
| # don't change sequence below |
setup | setup |
main | main |
{ | { |
"description": "json-file to backup and restore per backup-script", | "description": "json-file to backup and restore per backup-script", |
"job_seq":"mount_fs add_tasks.backup_opt replicate error_check", | "work_dir":"/data", |
| "log_dir":"/data/backuplog", |
| "log_remove":"yes", |
| "job_seq":"mount_fs add_tasks.backup_opt replicate error_check messaging", |
"jobs": | "jobs": |
{ | { |
{ | { |
"@":"'ping_target' is used to verify location; 'mount_def' can be 'file' or 'server'; in case of 'file', 'mount_file' needed", | "@":"'ping_target' is used to verify location; 'mount_def' can be 'file' or 'server'; in case of 'file', 'mount_file' needed", |
"ping_target":"<my server at home>", | "ping_target":"192.168.2.1", |
"mount_def":"file", | "mount_def":"file", |
"mount_opt":"-t glusterfs", | "mount_opt":"-t glusterfs", |
"mount_share":"<file server share>", | "mount_share":"<file server share>", |
"@":"'mount_file' describe a method to connect to a server and his share(s), 'mount_srv' and 'mount_share' not needed in this case", | "@":"'mount_file' describe a method to connect to a server and his share(s), 'mount_srv' and 'mount_share' not needed in this case", |
"mount_file":"<mount file with absolute path: i.e. /etc/bla/blabla.file>", | "mount_file":"/etc/glusterfs/gluster1.vol", |
"mount_point":"<target mount point>" | "mount_point":"/gluster" |
}, | }, |
"replicate": | "replicate": |
"@":"'repli_opt' can be 'local' or 'remote', 'remote' needs 'pass_option', 'sync_server' and 'sync_user'", | "@":"'repli_opt' can be 'local' or 'remote', 'remote' needs 'pass_option', 'sync_server' and 'sync_user'", |
"repli_opt":"local", | "repli_opt":"local", |
"@":"only rsync implemented yet, can try scp, but auth method must implemented by your self", | "@":"only rsync implemented yet, can try scp, but auth method must implemented by your self; use 'AX' to safe links", |
"method":"rsync", | "method":"rsync", |
"run_options":"-avh -partial", | "run_options":"-avh -partial", |
"log_options":"-avhn -partial", | "log_options":"-avhn -partial", |
"@":"pass_option : file content format 'username:password'", | "@":"pass_option : file content format 'username:password'", |
"pass_option":"--password-file=<file location>", | "pass_option":"--password-file=<file location>", |
"sync_user":"<username>", | "sync_user":"<username>", |
"@":"if absolute path used in 'sync_folders', not 'work_dir' needed", | "@":"if absolute path used in 'sync_folders', not 'work_dir' needed", |
"sync_folders":"<Folder 1> <Folder 2> <Folder 3>", | "sync_folders":"Carrier Closed Documentation Downloads notes privat Projekts Proposals transcripts backup transfer", |
"@":"'remote_folder' means the backup folder at the target file system", | "@":"'remote_folder' means the backup folder at the target file system", |
"remote_folder":"<folder name>" | "remote_folder":"Arbeit" |
}, | }, |
"error_check":"no further config parameter needed", | "error_check": |
| { |
| "@":"'err_ignore' means witch files or search words can be ignore in error log or errors at backup this files are normal (i.e. log-files)", |
| "err_ignore":"", |
| "@":"error level definitions", |
| "err_high":"", |
| "err_medium":"notes", |
| "err_low":"" |
| }, |
| "messaging":"<no further parameter needed, all included in backup script>", |
"add_tasks": | "add_tasks": |
{ | { |
{ | { |
"folder":"mysql_backup", | "folder":"mysql_backup", |
"task":"mysqldump -u root --password=<PASSWORD> --all-databases >" | "task":"mysqldump -u root --password=<PASSWORD> --all-databases > $TARGET" |
}, | }, |
"backup_opt": | "backup_opt": |
} | } |
} | } |
}, | |
"work_dir":"/data", | |
"log_dir":"/data/backuplog", | |
"log_remove":"no", | |
"error_hand": | |
{ | |
"@":"'err_ignore' means witch files or search words can be ignore in error log or errors at backup this files are normal (i.e. log-files)", | |
"err_ignore":"<patter i1> <patter i2> <patter in>", | |
"@":"error level definitions", | |
"err_high":"<patter h1> <patter h2> <patter hn>", | |
"err_medium":"<patter m1> <patter m2> <patter mn>", | |
"err_low":"<patter l1> <patter l2> <patter ln>" | |
} | } |
} | } |
| |
Die Jobs "mount_fs" und "replicate" sind als feste Optionen, siehe "job_seq" (Job Sequence), fertig definierte Schritte im BackupScript. Wobei auch "mount_fs" nur eine Option ist. Ich habe bei mir diesen Schritt gewählt, damit ich bei der Replikation keine Authentifizierung benötige und auch gleichzeitig auf zwei verschiedene Platten, bei mir zwei Server, schreiben kann. Wenn mir also ein Server, wegen was auch immer, nicht zur verfügung steht, dann kann ich trotzdem mein Backup machen. | |
| |
| Die Jobs "mount_fs" und "replicate" sind als feste Optionen, siehe "job_seq" (Job Sequence), fertig definierte Schritte im BackupScript. Wobei auch "mount_fs" nur eine Option ist. Ich habe bei mir "mount_fs" gewählt, damit ich bei der Replikation keine Authentifizierung benötige und auch gleichzeitig auf zwei verschiedene Platten, bei mir zwei Server, schreiben kann. Wenn also bei mir ein Server, wegen was auch immer, nicht zur Verfügung steht, dann kann ich trotzdem mein Backup machen. |
| |
"add_tasks" sind frei definierbare zusätzliche Aufgaben deren Auführungszeitpunkt in "job_seq" definiert wird. | "add_tasks" sind frei definierbare zusätzliche Aufgaben deren Auführungszeitpunkt in "job_seq" definiert wird. |