Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##prompt for user input and output##
- ##answers to variables ##
- read -p 'servername: ' -e server
- read -p 'tarname: ' -e tarname
- read -p 'server destination: ' -e destination
- ##main script function##
- sc_function ()
- {
- ##save server to make sure its completely new##
- service mc$server command save-all
- ##tar up server that needs tarred##
- tar -cvf $tarname.tar /home/$server/*
- ##copy paste file from local server to remote server##
- scp $tarname.tar root@"$destination":/var/www/$tarname.tar
- ##remove tarred file for cleanup purposes##
- rm /home/serverconfigs/deployscripts/$tarname.tar
- ##finish her up##
- echo "server $server backed up and moved to $destination /var/www/ "
- echo "You can now download the backup at http://$destination/$tarname.tar"
- }
- ##loop for a yes or no answer##
- while true; do
- echo "server $server will be backed up into $tarname.tar"
- echo "will transfer $tarname.tar to $destination /var/www/"
- echo "Then remove $tarname.tar from /home/serverconfigs/deployscripts/"
- ##read answer to a variable named yn##
- read -p "Is this correct [y/n]" yn
- case $yn in
- ##if variable equals Y or y then do the following##
- ##you can run multiple functions on this line, ##
- ##will execute in order, break is to end script ##
- ##if break isn't there the script will repeat ##
- [Yy]* ) sc_function; break;;
- ##if variable equals N or n then just exit script##
- [Nn]* ) exit ;;
- ##if anything else is typed prompt echo then repeat loop##
- * ) echo "please answer y or n.";;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment