Shell script to create list of backup files in ~/.mybackup file. Use with mybackup shell script
Posted in Backup
#!/bin/bash # mybackupadd - Add file to ~/.mybackup file, then backup and email all # file as tar.gz to your email a/c. # # Usage : ./mybackupadd ~/public_html/ # # Copyright (C) 2004 nixCraft project # Email : http://cyberciti.biz/fb/ # Date : Aug-2004 # ------------------------------------------------------------------------- # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- FILE=~/.mybackup MYH=~ CWD=`pwd` SRC=$1 if [ "$SRC" == "" ]; then echo "Must supply dir or file name" exit 1 fi # if list $FILE does not exist [ ! -f $FILE ] && touch $FILE || : # make sure that file or dir exists to backup if [ ! -f $SRC ]; then if [ ! -d $SRC ]; then echo "$SRC does not exists" exit 2 fi fi # make sure we don't do add duplicate stuff cat $FILE | grep -w $SRC > /dev/null if [ "$?" == "0" ]; then echo "$SRC exists in $FILE" exit 3 fi # okay now add that to backup list echo "$SRC" >> $FILE echo "$SRC added to $FILE"
Download - Email this to a friend - Printable version
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: backup files, cwd, echo command, email, exit 1, fi fi, free software foundation, gnu general public license, script collection, shell script, tar gz ~ Last updated on: April 9, 2008

