Bash wrapper for backing up Linux machine with bash version 4.0+. This program will run user provided backup configuration when called. It uses 2 global constants GL_BACKUP_CONFIG
and GL_PRMG_CONFIG
to choose the configuration files. They are set to the example file for demonstration purposes.
Please note, this script was written for bash learning and experimentation. There are likely better and simpler solutions available.
bash_backup -[ioRs]-[B ]
Action Parameters (choose one)
-i Run INITIAL Action
-o Run ONGOING Action
-R Run RESTORE Action
-s Run SHOW Action
-h Prints help message and exits
Backup ID
-B sets backup ID
bash_backup -i -B tar_local
bash_backup -s -B tar_local
bash_backup -o -B tar_local
bash_backup -R -B tar_local
0 Success
1 General Failure (varied message)
3 No entries found for "$CFG_BID:$CFG_ACTION"
4 Entry "$CONFIG_LINE" is incorrect or more then one line was found
5 $NUM_OF_ENTRIES entries found in $PRMG_CONFIG_FILE for "$PROGRAM:$ACTION"
6 $1 is unknown
7 Unable to use file: "$GL_BACKUP_CONFIG". (Does files exist and is it readable?)
8 File "$CONFIG" is not ASCII text type"
9 "$CONFIG" is not owned by root or $USERID (File owner: $config_user)
10 Wrong permissions on file: $CONFIG.(Is file write/executable by group/other?)
11 umask is invalid ($SET_UMASK)
12 More or less then one action set (count: $action_count)
13 Invalid argument entered -$OPTARG
14 $OPTARG requires an argument
15 Unknown remaining command line argument (args: $@ )
16 -B already set
17 BID was never set
18 BID has # in it ($cfg_BID)"
19 Command Line argument Missing
20 Could not cd to directory $WORKING_DIR
21 Bash-4.0+ is required to run this script
- Files must be ASCII text, owned by script user or root and only writable by owner
- Lines starting with '#' are comments
- Backup and program entries are stored in separate files
GL_BACKUP_CONFIG
determines backup fileGL_PRMG_CONFIG
determines the program file- entries are separated by a new line
- Fields in an entry are delimited by a ':'
- Fields are case sensitive
- Any entry with a default can be omitted.
<BID>:<Action>:<Program>:<Arguments>:<Source>:<Backup>:<cd>:<UMASK>
- BID - Name of Backup used to identify, when script is called
- Action - Name of supported backup action (INITIAL,ONGOING,SHOW,RESTORE).
Add multiple actions together separated by
,
- Program - program used for backup. Must be a program in prgm.config
- Arguments - list of Arguments to be passed to program. (Default is blank)
- Source - Path to source of backups. Can be directory or file_name (Default is blank)
- Backup - Path to backup. Can be directory or file_name (Default is blank)
- cd - Absolute path to change directory before running backup (Default is /)
- Umask - Set umask before running program (Default is not to change umask)
All entries begin with <program>:<action>
rearrange the other fields to make
program work on command line or omit it
- program - program used for backup.
- action - Name of supported backup action (INITIAL,ONGOING,SHOW,RESTORE)
add multiple actions together separated by
,
- arguments - list of Arguments to be passed to program.
- source - Path to source of backups. Can be directory or file_name
- backup - Path to backup. Can be directory or file_name
-
Anthony Tilelli
-
Linda Bissum (Mentor)