synbak-utils-0.0.1/000075500000000000000000000000001112520351300141245ustar00rootroot00000000000000synbak-utils-0.0.1/create-config.sh000075500000000000000000000012101112520351300171630ustar00rootroot00000000000000#!/bin/bash # Usage: ./create-config.sh # Example: ./create-config.sh `uname -n` tar . "${0%/*}"/synbak-utils-functions.sh #synbak_version=$(synbak -v | awk '// { print gensub("^version[[:space:]]*([^ ]+).*$","\\1","") }') example_config="/usr/share/synbak/template.conf" mkdir -p $(dirname $usr_file_conf) cp -f "$example_config" "$usr_file_conf" "${0%/*}"/write-param.sh "$1" "$2" report_html no "${0%/*}"/write-param.sh "$1" "$2" backup_source "/etc /home /root /var" "${0%/*}"/write-param.sh "$1" "$2" backup_destination '/var/synbak/$system/$method' "${0%/*}"/write-param.sh "$1" "$2" backup_exclude '/var/synbak *.tmp' synbak-utils-0.0.1/do-backup.sh000075500000000000000000000007171112520351300163350ustar00rootroot00000000000000#!/bin/bash # Do actual backup # Usage: do-backup.sh [extra_param] . /usr/share/synbak/functions.sh . "${0%/*}/synbak-utils-functions.sh" [ -n "$3" ] && extra_params="-M $3" [ -z "$3" -a x"$2" = x"tar" ] && extra_params="-M bz2" check_usr_file_conf file_config_field_import "$usr_file_conf" backup_destination path notnull [ -d "$backup_destination" ] || mkdir -p "$backup_destination" || exit 1 eval synbak -s "$1" -m "$2" "$extra_params" synbak-utils-0.0.1/do-restore.sh000075500000000000000000000015111112520351300165440ustar00rootroot00000000000000#!/bin/bash # Do restore from backup path using specified method # Usage: do-restore.sh . /usr/share/synbak/functions.sh . "${0%/*}/synbak-utils-functions.sh" [ -z "$3" ] && echo "Error: missing " && exit 1 backup_path="$3" check_usr_file_conf case "$method" in tar) tar -C / -xf "$backup_path" || exit 1 ;; rsync) file_config_field_import "$usr_file_conf" backup_incremental boolean notnull # If backup is incremental and used not last copy, first restore base copy if [ x"$backup_incremental" = x"yes" ]; then [ "${backup_path##*/}" = "backup-$system" ] || \ rsync -avPH "${backup_path%/*}/backup-$system"/ / fi # Then restore from specified copy rsync -avPH "$backup_path"/ / ;; *) echo "Error: unsupported method '$method'" > /dev/stderr exit 2 ;; esac synbak-utils-0.0.1/list-backups.sh000075500000000000000000000006271112520351300170710ustar00rootroot00000000000000#!/bin/bash # List existing backups . /usr/share/synbak/functions.sh . "${0%/*}/synbak-utils-functions.sh" check_usr_file_conf file_config_field_import "$usr_file_conf" backup_destination path notnull pattern="*" previous_dir="$PWD" cd $backup_destination || exit 2 # FIXME: force LC_COLLATE before sort find -maxdepth 1 -name "${pattern}" | sed -e 's/^.\///' | grep -wv ^"." | sort cd "$previous_dir" synbak-utils-0.0.1/list-methods.sh000075500000000000000000000000411112520351300170720ustar00rootroot00000000000000#!/bin/bash echo tar echo rsync synbak-utils-0.0.1/read-param.awk000075500000000000000000000012531112520351300166450ustar00rootroot00000000000000#!/bin/awk -f BEGIN { if (!param) { print "Error: missing \"param\", run with 'gawk -v param= ...'" > "/dev/stderr" exit 1 } param_read = 0 param_reg = "(^[[:space:]]*" param "[[:space:]]*=)([^#]*)?(#.*)?$" } function trim(arg) { gsub(/^[[:space:]]+/,"", arg) gsub(/[[:space:]]+$/,"", arg) return arg } // { if ($0 ~ param_reg) { if (param_read) { print "Warning: duplicated param \"" param "\"" > "/dev/stderr" } else { print trim(gensub(param_reg,"\\2","",$0)) param_read = 1 } } } END { if (!param) exit 1 if (!param_read) { print "Error: param \"" param "\" not found" > "/dev/stderr" exit 2 } } synbak-utils-0.0.1/read-param.sh000075500000000000000000000004571112520351300165020ustar00rootroot00000000000000#!/bin/bash # Read parameter for given system/method # Usage: read-param.sh . "${0%/*}/synbak-utils-functions.sh" [ -z "$3" ] && \ echo "Error: missing " >&2 && exit 1 param="$3" check_usr_file_conf cat "$usr_file_conf" | "${0%/*}/read-param.awk" -v param="$param" synbak-utils-0.0.1/synbak-utils-functions.sh000064400000000000000000000012731112520351300211160ustar00rootroot00000000000000#!/bin/bash [ -z "$1" ] || [ -z "$2" ] && \ echo "Error: missing or " >&2 && exit 1 system="$1" method="$2" echo "$system" | egrep -q '[ |"]' && \ echo "Error: space and \" disallowed in " >&2 && exit 2 echo "$method" | egrep -q '[ |"]' && \ echo "Error: space and \" disallowed in " >&2 && exit 2 # synbak functions.sh uses uninitialized var $file_status_config_field_import file_status_config_field_import="/dev/null" usr_dir="${HOME}/.synbak" usr_file_conf="${usr_dir}/${method}/${system}.conf" check_usr_file_conf() { if [ ! -f "$usr_file_conf" ]; then echo "Error: missing config for given and " >&2 exit 3 fi } synbak-utils-0.0.1/test-config-parser.sh000075500000000000000000000006111112520351300201750ustar00rootroot00000000000000#!/bin/bash # Test synbak config parser . /usr/share/synbak/functions.sh # functions.sh uses uninitialized var $file_status_config_field_import file_status_config_field_import="/dev/null" test_config="${0%/*}/test.conf" file_config_field_import $test_config backup_source path null echo $backup_source file_config_field_import $test_config backup_exclude path null echo $backup_exclude synbak-utils-0.0.1/test.conf000064400000000000000000000064341112520351300157610ustar00rootroot00000000000000#@ Synbak 1.2.x main configuration file #@ Usage: # 1) Put this file in your 'configuration directory'/'method name' and change # the name to systemname.conf (ex. /home/username/.synbak/rsync/thisserver.conf) # # 2) If you want execute automatically the backup script (suggested) # add to user crontab ('crontab -e') a line like this: # 00 00,8-20/4 * * 1-6 synbak -s thisserver -m rsync #@ Special system variables usable in this config file (they are case sensitive): # - $system (the system name you specified in command line) # - $method (the method name you specified in command line) # - $today (today date, in format YYYYMMDD, ex. '20030920') # - $onedayago (1 day ago date, in format YYYYMMDD, ex. '20030919') # - $twodayago (2 day ago date, in format YYYYMMDD, ex. '20030918') # - $threedayago (3 day ago date, in format YYYYMMDD, ex. '20030917') # - $xxxdayago (so on...) # - $HOME (your home directory, ex. '/home/username') #@@ remote backup (this is the base address to use for every backup_source entry. this valid only for remote methods) #backup_remote_uri = cifs://usr:pwd@host/path # valid URI: ssh, rsync, smb, cifs, mysql, oracle, ldap, http, ftp (the URI is dependant of backup method) #report_remote_uri_down = yes # yes = create the reports if the remote host is down. no = don't make any reports if the host is down #@@ mandatory backup fields backup_source = $HOME #source backup_destination = $HOME/backup backup_exclude = $HOME/backup *.swp *.tmp backup_incremental = yes # use incremental or total backups backup_erase_after = 3 # erase old backups after n. backups backup_no_make_destdir = no # don't make the auto created destination dir (aka: don't use a prefix for each backup, this disable the autoerase function) backup_erase_always = no # erase old backups even if an error occour in a backup step backup_method_opts = # additional backup method options (options used by the real backup command) #@@ tape backup #backup_device_changer = /dev/sg5 # the tape changer device path #backup_verify = no # verify the backup #@@ tape and laserdisc backup #backup_device_eject = no # eject the device at backup end #@@ misc reporting information report_info_support = InitZero S.r.l. - support@initzero.it # the techincal support info you want show to your customers #@@ standard output reporting report_stdout = yes # always generate standard output report report_stdout_on_errors = no # generate standard output report on errors only #@@ email output reporting report_email = no # always generate an email report report_email_on_errors = yes # generate email report on errors only report_email_rcpt = support@initzero.it # the detination email address of email reports #@@ html/rss output reporting report_html = yes # always generate a html report report_html_on_errors = yes # generate html report on errors only report_html_destination = /home/vyt/temp/synbak-reports # destination dir of html reports report_html_uri = http://localhost/admin/log/backup # uri of html and rss reports report_html_logo = yes # display a logo in the html report report_html_logo_image = # image path of the logo report_html_logo_link = http://www.initzero.it/products/opensource/synbak/ # uri link of the logo report_html_logo_image = synbak-utils-0.0.1/write-param.awk000075500000000000000000000013401112520351300170610ustar00rootroot00000000000000#!/bin/awk -f BEGIN { fail = 0 if (!param) { print "Error: missing \"param\", run with 'gawk -v param= -v value= ...'" > "/dev/stderr" fail = 1 exit 1 } param_inserted = 0 param_reg = "(^[[:space:]]*" param "[[:space:]]*=)([^#]*)?(#.*)?$" if (value ~ /"|[[:cntrl:]]/) { print "Error: control chars and \" not allowed in param value" > "/dev/stderr" fail = 1 exit 2 } } // { if ($0 ~ param_reg) { if (param_inserted) { print "Warning: duplicated param \"" param "\"" > "/dev/stderr" } print gensub(param_reg,"\\1 " value "\t\t\\3","",$0) param_inserted = 1 } else { print $0 } } END { if (!param_inserted && !fail) { print param "\t\t= " value } } synbak-utils-0.0.1/write-param.sh000075500000000000000000000011021112520351300167050ustar00rootroot00000000000000#!/bin/bash # Write parameter for given system/method # Usage: write-param.sh [value] . "${0%/*}/synbak-utils-functions.sh" [ -z "$3" ] && \ echo "Error: missing " >&2 && exit 1 param="$3" value="$4" check_usr_file_conf TMPFILE=`mktemp -t synbak-utils.XXXXXXXX` # Prepare values with escaped spaces for passing to awk value=$(echo "$value" | sed -e 's/\\/\\\\\\\\/g') cat "$usr_file_conf" | "${0%/*}/write-param.awk" -v param="$param" -v value="$value" > "$TMPFILE" || exit 2 cat "$TMPFILE" > "$usr_file_conf" || exit 3 rm -f "$TMPFILE"