Current position: Home > Default > I need help making a backup script
I need help making a backup script
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.
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...
- Read related articles
- Backup script
- How do I create a automated file backup script?
- Parallel Backup script written in python
- Unix Backup Script Question
- Schedule backup script ICM
- A decent cold backup script
- Rman hot backup script gives error in R12.
- Install & Backup Scripts - 1st try at scripting
- How do i create a backup script
- NT 의 OCOPY 를 이용한 HOT BACKUP SCRIPT
- Oracle Backup Script
- Launch daemon for svn backup script not working
- Oracle Hot Backup Script Windows Server 2003
- Help Needed With a Backup Script
- RMAN Backup Script not running in cron tab
- Running same backup script on two different Databases
- Require backup script which deletes the daily backups after weekly backup
- Win2000/NT hot backup script
- RMAN Level 0 backup script
-
Backup script
2015-10-11I created a backup script for my data & system and i'd like to share it. I have a 320GB hdd (1) as my main hard drive, and a 160GB hdd (2) as a backup drive (i keep this one in a drawer nearby, disconnected from the computer). What i wanted was to cr
-
How do I create a automated file backup script?
2015-10-11I need a backup script to move files from the MAC to Google Drive everyday at a certain time. I tried using automator to create a calendar flow but it does not run when I set it up in calendar. Can someone provide me a simple script template with
-
Parallel Backup script written in python
2015-10-11I'm writing a backup script in python, based on one I wrote in BASH earlier on. Both of these leverage rsync, but I decided to move to a python implementation because python is much more flexible than BASH. My goals with the new implementation are to
-
Unix Backup Script Question
-0001-11-30Hello - I want to compare file system dates (on AIX) for a backup script. For example, after the backup completes, I want to compare the timestamps on each backed up file with the the time the backup started. I should not see any timestamps prior to
-
Schedule backup script ICM
-0001-11-30Hello, I'm trying to backup script (*.ICMS) with schedule task, do you now if it's possible? I find the manual export in script editor but do it one by one ... I need your help Thanks a lotYou cannot "back up" an individual .icms file. If you ba
-
A decent cold backup script
-0001-11-30Oracle version : 11G release 2 Platform : AIX After going through various OTN posts, i wrote the below Cold backup script (Untested). If there are any unnecessary stuff or enhancements required, please let me know $ rman target / RMAN> run alloc
-
Rman hot backup script gives error in R12.
-0001-11-30hi experts i m facing following prob when run the backup script. 1 day before the same script runs correctily but now it gives me error at the allocatioion of channel rest of command run correctly. [[email protected] rman_log]# cat UAT_daily_rman_hot_bkp
-
Install & Backup Scripts - 1st try at scripting
-0001-11-30Here is my first real attempt at bash scripting. The first is a simple script to back up some of my files and configs everytime my comp is shutdown: #!/bin/bash #Archive and compress files tar -czf /home/casey/ArchBoxBak.tar.gz /home/casey/.bashrc /
-
How do i create a backup script
-0001-11-30please how do i create a backup script to run full backupuser9106453 wrote: please how do i create a backup script to run full backupIs there a reason that you don't want to use the one provided with the installation ?Read other 5 answers
-
NT 의 OCOPY 를 이용한 HOT BACKUP SCRIPT
-0001-11-30제품 : ORACLE SERVER 작성날짜 : 2002-04-25 NT 의 OCOPY 를 이용한 HOT BACKUP SCRIPT ======================================== PURPOSE 다음은 NT에서 OCOPY를 이용하여 HOT BACKUP을 하는 SCRIPT를 제공한다. Examples 1) <Batch file 1 > Online_backup_data 라는 batch file 은 다음처럼 이루어질 수 있다.
-
Oracle Backup Script
-0001-11-30I mean as we write a backup script to take backup of whole day working for Hr db like i use the following script to take backup of one user for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set fdate=%%a%%b%%c for /f "tokens=1,2,3,4,5 d
-
Launch daemon for svn backup script not working
-0001-11-30Hi, I would like to set up an automatic backup for our subversion repository and I therefore wrote a simple script. The script (see below) works fine if it's started in Terminal (with sudo), but if it is run as a launch daemon the svnsync command ins
-
Oracle Hot Backup Script Windows Server 2003
-0001-11-30Hello, Does anyone here have a working Oracle 10I database hot backup script for Windows Server 2003? If so can you please post it here. Thanks.Here is a basic batch script I have used for a hot backup of Oracle databases using RMAN Will just need to
-
Help Needed With a Backup Script
-0001-11-30I am writing a DNS server backup script with additional options. Backing Up DNS Server Daily Create a folder based on current date Copy the backup from source to newly created folder based on date Complicated part (well, for me anyway :) ) keeping c
-
RMAN Backup Script not running in cron tab
-0001-11-30Hi, I am having rman backup script which is being executed successfully through shell. but when scheduled in cron the script is being called but RMAN commands are not getting executed. i have scheduled cron using oracle user. Attached below the rman
-
Running same backup script on two different Databases
-0001-11-30Hello All, I am running same backup script on two different Databases. But output is different. Please give me your feedback. 1) Database 1: OS: AIX DB: 10.1.0.4.0 Script: export ORACLE_SID=sid1 cd $ORACLE_HOME/bin ./rman nocatalog << EOF connect ta
-
Require backup script which deletes the daily backups after weekly backup
-0001-11-30Hi, I am new to Oracle administration. I require a backup script which will delete the daily backups (incremental) after weekly backup is taken (full database backup). Currently I use Oracle 10g for one of my production server. My backup strategy is
-
Win2000/NT hot backup script
-0001-11-30Can someone provide a basci script for online(hot) backup for Oracle9i(8i) on Windows2000/NT server? we have a online application, and plan to back it up every night. Also, Windows should have administrative tool to schedule the backup by envoking th
-
RMAN Level 0 backup script
-0001-11-30Hi All, Required level 0 backup script. We have 10gR2 [10.2.0.4] Production instance, for backup required level 0 script. Regards ShaikShaik wrote: Hi All, Required level 0 backup script. We have 10gR2 [10.2.0.4] Production instance, for backup requi

Hots 
- 1Palm Desktop seems to back up only select data from Treo 650 10-11
- 2Mail account no longer shows 10-11
- 3Siri not working on iPad mini on iSO 6.1.3 10-11
- 4Is it possible to download your songs from the ipad to a separate harddrive? harddrive? 10-11
- 5SAP HCM Business analyst Support role Interview Questions and answers required.. 10-11
- 6Message mapping 10-11
- 7IPod problem with Adobe Photo Downloader 10-11
- 8Collaborating with a Graphic Designer 11-30
- 9Vendor Invoice - FB60 11-30

News 
- Multiple Libraries on 1 computer?10/11
- Why is it taking so long to download and watch on apple tv 3gn10/11
- Personal Laserwriter LS and 6.0.810/11
- 18 month old iMac 24" - is licence included?11/30
- WiFi on my iMac11/30
- Back up color scheme in KDE4 [SOLVED]11/30
- Servlet & JavaScript problem11/30
- Migrating Wiki from MoinMoin11/30
- How to convert single column into single row11/30
- How i can install win 7 on lion osx11/30