2 Commits
1.2 ... 1.2.1

Author SHA1 Message Date
a708ec80ca Add user option
Added a command line option to specify the user performing the backup.
This is useful if running the program with sudo.
2015-11-26 01:03:33 +01:00
f5365fddff Add warning in example configuration 2015-11-25 13:26:57 +01:00
2 changed files with 15 additions and 3 deletions

2
config
View File

@ -1,5 +1,7 @@
#Example config file for my_backup #Example config file for my_backup
# WARNING: Values should NOT be quoted, e.g. use inputs=/some/dir instead of inputs="/some/dir"
#Input directories. Use a comma to separate items #Input directories. Use a comma to separate items
inputs=/home/my_home,/etc inputs=/home/my_home,/etc

View File

@ -15,7 +15,7 @@
#You should have received a copy of the GNU General Public License #You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>. #along with this program. If not, see <http://www.gnu.org/licenses/>.
#Version 1.2 #Version 1.2.1
#Simple backup script. Reads options, sources and destination from a configuration file or standard input #Simple backup script. Reads options, sources and destination from a configuration file or standard input
#Help function #Help function
@ -35,6 +35,8 @@ function help_function {
echo " the backup." echo " the backup."
echo "-k, --keep NUMBER Specify the number of old backups to keep." echo "-k, --keep NUMBER Specify the number of old backups to keep."
echo " Default: keep all." echo " Default: keep all."
echo "-u, --user USER User performing the backup."
echo " Default: current user."
echo "" echo ""
echo "If no option is given, the program uses the default" echo "If no option is given, the program uses the default"
echo "configuration file: $HOME/.simple_backup/config." echo "configuration file: $HOME/.simple_backup/config."
@ -270,13 +272,21 @@ function parse_options {
;; ;;
-c | --config) -c | --config)
if [[ -f "$EXCLUDE" ]]; then
rm "$EXCLUDE" rm "$EXCLUDE"
fi rm "$INPUTS"
read_conf "$2" read_conf "$2"
return return
;; ;;
-u | --user)
rm "$EXCLUDE"
rm "$INPUTS"
config="/home/$2/.simple_backup/config"
read_conf "$config"
return
;;
*) *)
echo "$(date): Backup failed (see errors.log)" >> $HOME/.simple_backup/simple_backup.log echo "$(date): Backup failed (see errors.log)" >> $HOME/.simple_backup/simple_backup.log
echo "Error: Option $1 not recognised. Use 'simple-backup -h' to see available options" | tee -a $HOME/.simple_backup/errors.log echo "Error: Option $1 not recognised. Use 'simple-backup -h' to see available options" | tee -a $HOME/.simple_backup/errors.log