I need help making a backup script

I'm trying to create this full system backup script that I plan to run manually. I have some commands to compress and extract my root directory and everything in it, but they're not complete because there are a few other features I would like to have. The problem is that I have no idea how to implement these specific features, and my googling of bash scripting documentation only left me confused and at square 1. This is what I have so far (just commands I can run in the terminal):
To compress:
sudo tar -cpf ~/archive.tar.gz / --exclude=/proc
To extract & restore:
sudo tar -xpf /home/agi/archive.tar.gz -C /
I want this script to:
1. allows me to run as
sh ~/.bin/backup.sh [directory to back up]
What I mean is there should be some sort of parameter in the script so that when I run it, I can choose whatever directory I want to compress rather than just be limited to just /.
2. puts finished .tar.gz in my home directory (I plan to transfer the archive to external media or online later; this gives me the freedom to not need to have a specific drive connected to run the script). I already have this in the commands, but I just wanted to point out that this is important.
3. names finished .tar.gz DD-MM-YY-backup.tar.gz where DD is day, MM is month, YY is year.
4. the "sudo" part works correctly. That is, the script, when run, asks for a password and can be granted root permissions (or is granted root permissions in some other way) so that I can back up all parts of my system without these sorts of errors.
5. shows some sort of progress indicator. Either a progress bar, shows the tar program output, or something that gives me an indication that the script is working and perhaps how long it will take. This one is really optional, for as long as the process is working properly then I'm ok. But if it is possible and not ridiculously complicated or difficult, it would be very nice.

What I mean is there should be some sort of parameter in the script so that when I run it, I can choose whatever directory I want to compress rather than just be limited to just /.
On my backup script, I specify $* which should accept any arguments passed to the script.. ex: $ ./backup.sh /source/folder /source/folder2.
in the script:
#!/bin/sh
tar -cpf $HOME/$(date +%d%m%Y)-backup.tar.gz $* --exclude=/proc
2. puts finished .tar.gz in my home directory (I plan to transfer the archive to external media or online later; this gives me the freedom to not need to have a specific drive connected to run the script). I already have this in the commands, but I just wanted to point out that this is important.
In the above script, that is what the ~ or $HOME should do..
3. names finished .tar.gz DD-MM-YY-backup.tar.gz where DD is day, MM is month, YY is year.
Same thing, the above script should do the trick, you might want to modify the date parameters (check the date manual)
4. the "sudo" part works correctly. That is, the script, when run, asks for a password and can be granted root permissions (or is granted root permissions in some other way) so that I can back up all parts of my system without these sorts of errors.
You could put something to prevent the script from running unless you are root, or you could have it prompt for a password and use sudo within the script. I would recommend the first. Here is a code snippet:
#Check for root
if [ $(whoami) != "root" ]; then
echo "Error: You cannot perform this operation unless you are root"
exit 1
fi
5. shows some sort of progress indicator. Either a progress bar, shows the tar program output, or something that gives me an indication that the script is working and perhaps how long it will take. This one is really optional, for as long as the process is working properly then I'm ok. But if it is possible and not ridiculously complicated or difficult, it would be very nice.
You might be able to use a similar program to tar, but with progress. Maybe someone else could shed some light here..
Hope this helps...

Similar Messages

  • Need help making a simple script for my webcam

    Hey everyone, fairly new to applescript programming. I just bought a usb camera for my macbook because I use it for video conferencing/playing around, and it is better quality than the built in isight. However, in order to use this camera I need to use drivers from a program called camTwist. This being said camTwist needs to be opened first and the usb camera must be selected from camTwist Step 1 list in order for any other application to use the camera. I just want to make a simple program that would open camTwist first, then select "webcam" from the list (double click it like I always have to in order to select it) in order to activate the driver, and then open photo booth which would then be using the camTwist driver in order to take pictures.
    I made a crude program but it does not automatically select "webcam" from the Step 1 list in camTwist:
    tell application "CamTwist" to activate
    delay 10
    tell application "Photo Booth" to activate
    that’s basically it. I set the delay to 10 seconds so that when camTwists boots up first I can manually select my webcam. HOWEVER, I would like to make a script that would boot up CamTwist first, select my webcam from the list automatically, and then open Photo Booth with the CamTwist webcam driver already selected.
    Don't know much about applescript so any help to make a working script to solve my problem would be greatly appreciated! Thanks!

    Solved my problem but now I need help with something else! First I used CamTwist user options to create user defined hot keys with the specific purpose to load the webcam. I chose Command+B. I tested it out in CamTwist and it worked. The program follows a logical order from there. First it loads CamTwist, then after a short delay it presses the hot keys in order to load the webcam from the video source list, then another short delay and Photo Booth is opened with the driver loaded from camTwist. Everything works Perfect! Here's the code:
    tell application "System Events"
    tell application "CamTwist" to activate
    delay 0.5
    --Press command+b which is a user defined hot key to load webcam
    key code 11 using command down
    end tell
    delay 0.5
    tell application "Photo Booth" to activate
    My Next question is, would it be possible with this same script to have both applications quit together. For example I always quit Photo Booth first, so when I quit photo booth is there a way to make CamTwist also quit and keep everything within the same script? Please let me know. This forum has been very helpful and lead me to a solution to my problem! Hoping I can solve this next problem as well! Thanks everyone.

  • I need help making Adobe Edge animation appear correctly on iphones, ipads and android phones.

    I need help making Adobe Edge animation appear correctly on iphones, ipads and android phones. It currently looks fine on desktops and androids. I am using wordpress with a responsive theme (Canvas). I will need you to document The url is http://adamhtc.org.s183459.gridserver.com.

    Thanks George, interesting thought.  I looked on Adobe's site and they "advertise" fillable forms for the iPhone and Android markets, but on the Windows Phone tab, that is mysteriously missing.  lol    Maybe it will come later?   Meanwhile, I'll google to see if there are any PDF viewers that can handle it now.   Thanks for the reply.  :-)

  • My grandma is a new apple user and she needs help making an apple account.

    my grandma is a new apple user and she needs help making an apple account.

    She should call Apple support or visit the Genius Bar at an Apple store (make an appointment first at http://apple.com/retail). They will walk her through the process.

  • Need help for DB backup through OEM 11g grid

    I need to know how to schedule the hot backup of whole DB using OEM 11g grid.
    In our system there is a backup running for DB (10gr2). It is not scheduled through jobs.
    I am not able to find this scheduled db backup information from OEM.
    Can anyone guide me how to check the current backup schedules and backup script ?
    Is there any good document for this ?

    Hi Dhaval,
    You may look out option for restore backup from production and restore the same on QAS.
    Refer SAP note
    683447
    SAP Tools for MS SQL Server
    Which shall help you with post restore steps on the database.
    Once DB and SAP is up you may perform generic post restore steps like
    - STMS re-configuration
    - Adjusting profiles
    - Executing BDLS
    - Importing RFCs and user master ( if exported before the restore)
    - Adjusting Partner profiles
    - Configuring backup
    - Apply SAP license
    Above are just a few of them to name. There could be many more as per customer landscape.
    Regards,
    Deepak Kori

  • [solved]Need help with a bash script for MOC conky artwork.

    I need some help with a bash script for displaying artwork from MOC.
    Music folders have a file called 'front.jpg' in them, so I need to pull the current directory from MOCP and then display the 'front.jpg' file in conky.
    mocp -Q %file
    gives me the current file playing, but I need the directory (perhaps some way to use only everything after the last  '/'?)
    A point in the right direction would be appreciated.
    thanks, d
    Last edited by dgz (2013-08-29 21:24:28)

    Xyne wrote:
    You should also quote the variables and output in double quotes to make the code robust, e.g.
    filename="$(mocp -Q %file)"
    dirname="${filename%/*}"
    cp "$dirname"/front.jpg ~/backup/art.jpg
    Without the quotes, whitespace will break the code. Even if you don't expect whitespace in any of the paths, it's still good coding practice to include the quotes imo.
    thanks for the tip.
    here it is, anyhow:
    #!/bin/bash
    filename=$(mocp -Q %file)
    dirname=${filename%/*}
    cp ${dirname}/front.jpg ~/backup/art.jpg
    then in conky:
    $alignr${execi 30 ~/bin/artc}${image ~/backup/art.jpg -s 100x100 -p -3,60}
    thanks for the help.
    Last edited by dgz (2013-08-29 21:26:32)

  • I'm a Noob, and need help solving a backup issue.

    I previously had an Alienware PC with a 1TB harddrive.  I backed up to the cloud using Carbonite.
    I decided to get a new laptop and got a MacBook Pro with Retina.  It only has 128GB harddrive.  My plan was to use a 2TB external harddrive and back up both using Carbonite.  Well, turns out Carbonite only does external harddrive backup with PC's not Macs.  So, I need help.
    I have way more files than can fit on my laptop that need to be accessed and backed up on a regular basis, so it would seem time machine isn't the solution.
    What do you do? or would you recommend?  What is the best way for someone like me who wants continual access to and backup of a large amount of data?  Are there any good cloud based solutions you would recommend?
    I appreciate your help!

    CMCSK
    Bulletproof backups:
    The MOST important part in that link was the titled portion marked: Make backups for your backups
    My list  for the original poster:
    Never consider any computer a data storage device, rather a data creation ,sending, and manipulation device. Anyone who thinks data is safe on any computer, even copied upon multiple partitions is making a mistake.
    Never backup your data exclusively upon magnetic hard drives or flash storage, nor consider same since magnetic storage degrades over time even under ideal conditions.
    Store important data on multiple servers on multiple continents. 
    Burn important data onto multiple copies of archival DVDs and store same in cool dark fireproof safes, hidden places, secret places, multiple places.
    Don’t burn data onto junk DVD’s purchased from consumer level electronics stores. These are not archival long life DVD’s nor reliable, nor trustworthy
    When data can be made to be everywhere, then there is nowhere it can be erased or destroyed.
    Most importantly know that 2 copies of your data is 1, and 1 is none, and 1000 copies stored in one place or building, is also the same as none when a fire occurs.
    Always consider and expect your computer’s hard drive to completely crash anytime, at all times, and thou shalt keep a cloned and updated hard drive handy at all times to return to immediate productivity and avoid program and parameter reinstallation and tweaking.
    When your data is decentralized, it becomes both everywhere and nowhere, accessible to all, destructible by none, cannot be collected together or permanently retrieved under any circumstances.

  • I need help with a backup file that was deleted and now undeleted from my hard drive

    Last month (May 6, 2011), I was updating my iPod Touch 4G with the new software that came out. I always make a backup of my iPod's data before I update it. While my iPod was updating I left my iPod and computer alone and was doing things around the house with my mom. And when I was done I went in my room to see if it was done and my computer decides that it was going to freeze and crash on me (with my iPod plugged in and stuck on the updating or verifying software mode.) I managed to get my iPod back to working condition again but losing everything on my iPod. I formatted my computer hard drive but I managed to get back the backup I lost. I need help on getting the backup into iTunes so I can get my data back. I am not Jailbroken and I plan not to Jailbreak. I however saved the backup file in a folder other than the Mobilesync folder. I am also running on Windows XP. Someone please help me and thank you in advance!

    I was able to backup my iPod and I tried to restore my iPod again and it goes through the process and everything but it restores the temporary data that I had on there. It didn't restore application data or the current photos and videos that I had saved in Camera Roll before this all had happened. It is almost like it goes back to factory settings but I have some photos that were saved on the other backup that I was temporarily running on. The backup that I am looking to restore is the only backup file in the Mobilesync folder as of right now the others are saved somewhere safe for right now. Why doesn't it restore my application data or my Camera Roll pictures and videos that I saved before my computer crashed last month? Can this problem be fixed?

  • Need Help making a Screencast for IPHONE

    Hello there
    I need some serious help making a screencast for a client - for it's Iphone Apps -
    something similare to this
    http://www.newsluxe.com/chaumet-et-iphone.php
    but more sexy, with a animated background and a different type of cursor.
    Anyideas ?
    I really don't know where to start - I found leads however :
    Camtasia Studio , screenflow, ,
    Maybe you could help me filling the gaps.
    Thanks for your help !

    does anyone know how apple made these forums?
    I think they use Jive:
    http://www.jivesoftware.com/products/forums/
    The Apple way for users to add photos is the .Mac web gallery:
    http://www.apple.com/ilife/iphoto/#webgallery

  • I need help finding a backup history?

    i need help figuring out how to restore my ipod  its back up but i was wondering if there is some how a feature where i can find like a back up history so i can restore my ipod to a backup from a different date instead of the last backup any ideas? I accidentally jacked up my ipod and i need to see if i can go to a sort of backup history from apple so i can restore my ipod from a different date instead of the LAST back up

    This shows what I see if I use the Edit > Preferences > Devices in iTunes.
    (Use Alt or Ctrl+B if you don't see the menu bar.)
    It shows just one backup for each of four devices (I don't normally update at this machine). As I recall if there were more, the additional backups would contain the restore date as part of the left-hand column.
    I suspect you're not going to like what you find.
    tt2

  • Need help publishing a php script

    I am reading the book Dreamweaver CS5 with PHP training from the source and I have reached page 247. I want to publish a registration field to my site, but I have encountered a problem I cannot solve. The file path in library works fine on the local testing server since it has access to my user folder. When I am uploading the site to my remote server, i can't seem to find the right file path at the beginning of library.php
    The code looks like this now
    <?php
    $library = '/home/1/r/rentsch/Scripts/php_library/ZendFramework/library';
    When I press the register button on the page I get this message:
    Warning: include_once(Zend/Validate/Stringlength.php) [function.include-once]: failed to open stream:
    No such file or directory in /home/1/r/rentsch/Scripts/php_library/ZendFramework/library/Zend/Loader.php
    on line 146
    Warning: include_once() [function.include]: Failed opening
    'Zend/Validate/Stringlength.php' for inclusion
    (include_path='.:/usr/local/php5-suphp/lib/php:/home/1/r/rentsch/Scripts/php_library/ZendFramework/library')
    in /home/1/r/rentsch/Scripts/php_library/ZendFramework/library/Zend/Loader.php
    on line 146
    Fatal error: Class 'Zend_Validate_Stringlength' not found in /home/1/r/rentsch/www/fredrik/Seterpaintball/zend_filer/user_registration.php
    on line 16
    Before I had that file path I got this message:
    Warning: require_once(Zend/Loader/Autoloader.php) [function.require-once]: failed to open stream:
    No such file or directory in /home/1/r/rentsch/www/fredrik/Seterpaintball/zend_filer/library.php
    on line 4
    Fatal error: require_once() [function.require]: Failed opening required
    'Zend/Loader/Autoloader.php'
    (include_path='.:/usr/local/php5-suphp/lib/php:rentsch/Scripts/php_library/ZendFramework/library')
    in /home/1/r/rentsch/www/fredrik/Seterpaintball/zend_filer/library.php
    on line 4
    I am renting a server from domainnameshop.com (in norway)
    And the page I am trying to upload to is www.rentsch.no/fredrik/Seterpaintball/registrer.php
    It is on norwegian, but it is the button that sais registrer that triggers the errors.
    I really need help on this, I can't find any solution on my own!

    I am reading the book Dreamweaver CS5 with PHP training from the source and I have reached page 247. I want to publish a registration field to my site, but I have encountered a problem I cannot solve. The file path in library works fine on the local testing server since it has access to my user folder. When I am uploading the site to my remote server, i can't seem to find the right file path at the beginning of library.php
    The code looks like this now
    <?php
    $library = '/home/1/r/rentsch/Scripts/php_library/ZendFramework/library';
    When I press the register button on the page I get this message:
    Warning: include_once(Zend/Validate/Stringlength.php) [function.include-once]: failed to open stream:
    No such file or directory in /home/1/r/rentsch/Scripts/php_library/ZendFramework/library/Zend/Loader.php
    on line 146
    Warning: include_once() [function.include]: Failed opening
    'Zend/Validate/Stringlength.php' for inclusion
    (include_path='.:/usr/local/php5-suphp/lib/php:/home/1/r/rentsch/Scripts/php_library/ZendFramework/library')
    in /home/1/r/rentsch/Scripts/php_library/ZendFramework/library/Zend/Loader.php
    on line 146
    Fatal error: Class 'Zend_Validate_Stringlength' not found in /home/1/r/rentsch/www/fredrik/Seterpaintball/zend_filer/user_registration.php
    on line 16
    Before I had that file path I got this message:
    Warning: require_once(Zend/Loader/Autoloader.php) [function.require-once]: failed to open stream:
    No such file or directory in /home/1/r/rentsch/www/fredrik/Seterpaintball/zend_filer/library.php
    on line 4
    Fatal error: require_once() [function.require]: Failed opening required
    'Zend/Loader/Autoloader.php'
    (include_path='.:/usr/local/php5-suphp/lib/php:rentsch/Scripts/php_library/ZendFramework/library')
    in /home/1/r/rentsch/www/fredrik/Seterpaintball/zend_filer/library.php
    on line 4
    I am renting a server from domainnameshop.com (in norway)
    And the page I am trying to upload to is www.rentsch.no/fredrik/Seterpaintball/registrer.php
    It is on norwegian, but it is the button that sais registrer that triggers the errors.
    I really need help on this, I can't find any solution on my own!

  • I recently updated to IOS6 and I cannot sync my calendar to icloud and all my notes are not appearing in cloud.  If I have a new calendar entry, it is on my phone, but not on icloud.   Need help making sure I don't lose any informaiton.

    I recenly updated to IOS6.  I have a couple issues after the process.
    1- I lost all my calendar entries after the date I upgraded to IOS6 (all before the date were there).  I created an icloud account to assure that I would not lose any going forward.  Now when I enter a calendar entry, it does not appear on my icloud account.  I can enter it in icloud and it will appear on my phone, but not the reverse. 
    2 - None of my notes transferred into icloud.  I tried to manually enter one on icloud, again so I wouldn't lose this information going forward, and it appears on my iphone twice.  I cannot figure out how to get the notes currently on my iphone into my icloud account.

    you need to do a backup of the old phone and then on your new phone restore from that backup
    look at the link for more detailed instructions  http://support.apple.com/kb/HT1414

  • I need help making a square that scans across a screen.

    i'm trying to make a program that creates images of a square scanning across a black background.  so far all i have is a program that makes one image where i can alter the size of the square and its position.  I'm very very new to labview and i need help with the structure that would create all the images of the square scanning across and then shift down and scan across again.
    thank you very much,
    Joseph Sadler
    Attachments:
    Drawexample.vi ‏24 KB

    As Lynn found, there is a memory problem with the vi which didn't show up in my limited testing.
    Using Shift Registers with Picture Controls can cause problems.
    See this thread.
    Try the attached "mod" version.
    Then I got to thinking, why redraw the box (2x with "erase") - when you could just move a box around?
    (Note: I used a picture for the box, but you could use other objects.)
    The "mod1" version does it this way.
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.
    Attachments:
    squarescan mod.vi ‏20 KB
    squarescan mod 1.vi ‏20 KB

  • I need help making a new Arch install ISO

    I have posted a couple of messages, but as yet no one seems to have responded, probably because they have not read them.
    I need help building a new ISO for Arch, to take account of dmraid.
    I can and have built ones that get so far, and clearly I am not that far away.
    All I need help with now is getting at the contents of the initial ramdisk (/isolinux/initrd.img) so I can make a new one with modifications, and if anyone can help, I need a hand working out how to use the kernel26.img that I will end up with on a system.
    Any help appreaciated.

    As far as I know this will be included in the next ISO release. I solved it by manually bringing the dmraid package to the install and wrote a guide on installing your root system on dmraid. However when the system crashes I have the slight inconvenience of having to install dmraid and manually mount the sets to do a recovery. I guess this is the part you want to get rid of aswell. I decided to wait until the next holy ISO.

  • Need help to modify vb script used in XP for Windows 7

    Can somebody help me in modifying scripts that were used for Windows XP, to run on Windows 7.
    My friend advised me to change it to .ps1, but still some flaws..
    Cscript \\nologo ????  is used for what purpose ?

    Almost all VBScripts written to work in Windows XP will also work for Windows 7, so there's not much to modify (unless you have specific examples of scripts not working).
    Having said that, PowerShell is the future! It takes a bit more than to just change the file extension to .ps1 though (this may be why your scripts aren't working!).
    The VBScript-to-Windows PowerShell Conversion Guide
    http://technet.microsoft.com/en-us/library/ee221101.aspx
    C:\>cscript /?
    Microsoft (R) Windows Script Host Version 5.7
    Copyright (C) Microsoft Corporation. All rights reserved.
    Usage: CScript scriptname.extension [option...] [arguments...]
    Options:
     //B         Batch mode: Suppresses script errors and prompts from displaying
     //D         Enable Active Debugging
     //E:engine  Use engine for executing script
     //H:CScript Changes the default script host to CScript.exe
     //H:WScript Changes the default script host to WScript.exe (default)
     //I         Interactive mode (default, opposite of //B)
     //Job:xxxx  Execute a WSF job
     //Logo      Display logo (default)
     //Nologo    Prevent logo display: No banner will be shown at execution time
     //S         Save current command line options for this user
     //T:nn      Time out in seconds:  Maximum time a script is permitted to run
     //X         Execute script in debugger
     //U         Use Unicode for redirected I/O from the console
    C:\>
    Andreas Hultgren
    MCTS, MCITP
    http://ahultgren.blogspot.com/

Maybe you are looking for

  • Problem while trying to execute Java class in JSP using  RunTime Class

    Hi, I want to execute a JAVA class through a JSP. For this I am using following code .... JSP (AAA.jsp) CODE ............ try String[] cmd = new String[3]; cmd[0] = "cmd.exe" ; cmd[1] = "/C" ; cmd[2] = "java -DPeBS_CONFIG_HOME=D:/CASLIntegration/PeBS

  • Disable framebuffer support??

    What do I lose if I disable framebuffer support in the kernel? My console has been unusable (text is huge and doesn't fit on screen) since I did a pacman -Syu a couple of weeks ago. I'm thinking that building my own kernel with framebuffer support di

  • Broken phone. Still in contract. Can I pay ETF and sign back up with Edge?

    Please help me with the best option for my situation: I have a broken phone and about a year left on my contract. I ultimately would like to get on edge when I ge ta new phone. Would I be able to pay the early termination fee to get out of my contrac

  • E71 - Issue with setting up email

    HI All My partner and I have both brought E71's, I set up access to my email easily then went to do my partners phone and we get up to the enter email address step and it kicks us out and wont let us enter a password or anything....not sure what is g

  • Gnome-cups-manager and rolling release

    can anyone make an update of gnome-cups-manager for voodoo? it as been 6 months since the last one...some help here please