Results 1 to 2 of 2

Thread: My first shell script, criticism welcome!

  1. #1
    Join Date
    May 2015
    Beans
    6

    Exclamation My first shell script, criticism welcome!

    Hello Ubuntu forums!
    I am new to Ubuntu, and so far have done several things I am quite proud of:

    • Made an apache webserver with my own html (before a week ago I had never touched it)
    • Made a stratum mining server +titcoin node


    And my latest project is making a shell script to backup my ENTIRE (that’s right) hard drive to a huge external one. Getting to the point, I know there’s quite a bit I could improve on, and I would like your opinion on it:

    Code:
    #!/bin/bash
    read -n1 -p “Would you like to back up your system? Uno for Si, and Dos for No.” input
    echo
    case $input in
    1) fdisk -l;
    echo;
    read -p “Please enter the name of your backup disk that was displayed in the fdisk window: ” disk ;
    echo;
    echo “Backups now in progress! Please be aware that backups are saved to a Backups directory which this script creates, and backups are tarred and labelled by date!”;
    echo “THIS WILL TAKE A VERY VERY LONG TIME IF YOU HAVE A LARGE FILESYSTEM! PLEASE BE PATIENT!!!”;
    cd /;
    sudo mkdir -p /mnt/$disk && sudo mount /dev/$disk /mnt/$disk && sudo mkdir -p /mnt/$disk/Backups && sudo tar -cp $(date +%Y%m%d).tar --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups . && sudo cp $(date +%Y%m%d-%H).tar /mnt/$disk/Backups;
    echo “Okay, all done! To restore your system, you will have to untar and manually do it yourself. If you have any issues, email harmius@icloud.com!”;;
    2) echo “Then why are you running this script?”;;
    *) echo “I'm sorry, but I can’t do that…”

    esac
    Honestly, I have no idea what I am doing. Any suggestions?



  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: My first shell script, criticism welcome!

    Thread closed. Duplicated thread here: http://ubuntuforums.org/showthread.php?t=2277286

    Please do not post duplicates. Besides diluting the community effort, it is very difficult to provide any consistent help.

    Please continue the conversation on the other thread.

    Regards.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •