gacanepa

backupninjahelper

Nov 29th, 2014
230
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Backup action's description. Separate words with underscores.
  2. HELPERS="$HELPERS home:backup_of_home_directories"
  3.  
  4. home_wizard() {
  5.    home_title="Home action wizard"
  6.  
  7.    backupname=`hostname --fqdn`
  8.  
  9. # Specify default value for the time when this backup actions is supposed to run
  10.    inputBox "$home_title" "When to run this action?" "everyday at 01"
  11.    [ $? = 1 ] && return
  12.    home_when_run="when = $REPLY"
  13.  
  14. # Specify default value for backup file name
  15.    inputBox "$home_title" "\"Name\" of backups" "$backupname"
  16.    [ $? = 1 ] && return
  17.    home_backupname="backupname = $REPLY"
  18.    backupname="$REPLY"
  19.  
  20. # Specify default directory to store the backups
  21.    inputBox "$home_title" "Directory where to store the backups" "/var/backups/home"
  22.    [ $? = 1 ] && return
  23.    home_backupdir="backupdir = $REPLY"
  24.  
  25. # Specify default values for the radiobox
  26.    radioBox "$home_title" "Compression" \
  27.        "none"     "No compression" off \
  28.        "gzip"     "Compress with gzip" on \
  29.        "bzip"     "Compress with bzip" off
  30.    [ $? = 1 ] && return;
  31.    result="$REPLY"
  32.    home_compress="compress = $REPLY "
  33.  
  34.    REPLY=
  35.    while [ -z "$REPLY" ]; do
  36.       formBegin "$home_title: Includes"
  37.          formItem "Include:" /home/gacanepa
  38.       formDisplay
  39.       [ $? = 0 ] || return 1
  40.       home_includes="includes = "
  41.       for i in $REPLY; do
  42.          [ -n "$i" ] && home_includes="$home_includes $i"
  43.       done
  44.    done
  45.  
  46.    REPLY=
  47.    while [ -z "$REPLY" ]; do
  48.       formBegin "$home_title: Excludes"
  49.          formItem "Exclude:" *.mp3
  50.          formItem "Exclude:" *.mp4
  51.          # Add as many “Exclude” text boxes as needed to specify other exclude options
  52. formItem "Exclude:"
  53.          formItem "Exclude:"
  54.       formDisplay
  55.       [ $? = 0 ] || return 1
  56.       home_excludes="excludes = "
  57.       for i in $REPLY; do
  58.          [ -n "$i" ] && home_excludes="$home_excludes $i"
  59.       done
  60.    done
  61.  
  62. # Save the config
  63.    get_next_filename $configdirectory/10.home
  64.    cat > $next_filename <<EOF
  65. $home_when_run
  66. $home_backupname
  67. $home_backupdir
  68. $home_compress
  69. $home_includes
  70. $home_excludes
  71.  
  72. # tar binary - have to be GNU tar
  73. TAR    `which tar`
  74. DATE    `which date`
  75. DATEFORMAT     "%Y-%m-%d"
  76. EXTENSION    tar
  77.  
  78. EOF
  79. # Backupninja requires that configuration files be chmoded to 600
  80.    chmod 600 $next_filename
  81. }
RAW Paste Data