Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # get the content of the $1 file, and uses it to extract bases to backup.
- # a server begins with servername
- # then, a relative list of bases to save, with user and passes : base user pass
- # server ends with a blankline
- todo=$1
- blankline="true"
- basedir=/media/backup/bases
- backit() {
- ssh backup-us@$server "mysqldump -u$user -p$pass $instruct | gzip" > $basedir/$instruct/$(date +%Y-%m-%d).gz
- }
- cat $todo | while read instruct
- do
- echo instruct = $instruct
- if [ "$instruct" != "" ]
- then
- echo instruct != ""
- if [ "$blankline" == "false" ]
- then
- echo base = $instruct
- mkdir -p $basedir/$instruct
- echo $(backit)
- fi
- if [ "$blankline" == "true" ]
- then
- i=0
- for val in $instruct
- do
- if [ "$i" -eq "0" ]
- then
- server=$val
- elif [ "$i" -eq "1" ]
- then
- user=$val
- elif [ "$i" -eq "2" ]
- then
- pass=$val
- fi
- i=$(( $i + 1 ))
- done
- echo conninfos = $server $base $user $pass
- blankline="false"
- fi
- fi
- if [[ "$instruct" == "" ]]
- then
- blankline="true"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement