Daily backup script

im trying to create a script to backup files on daily basis, but i have one bigger and a smaller problem.
i know how to create a folder with date (create folder then add current date to it), but i don't know how to put files in this to-be-made directory.
the first smaller thing is it would be nice to copy the whole path along with the file - maybe as a comment even, or as actual path.

Hi! I don't see any reason not to use it for backing up multiple drives especially since if you pay the 27 bucks or so you can schedule auto backups. Persoanlly I like having everything on one drive so I went from a 120 gig to 320 gig drives and I am slowly picking up 400 and 500 gig drives that I usually partition to backup other drives. Tom

Similar Messages

  • Require backup script which deletes the daily backups after weekly backup

    Hi,
    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 given below.
    I would like to take full database backup weekly(online). To be precise, on Saturday.
    I need to have daily incremental backup and they should get deleted on Saturday after the weekly full database backup is taken.
    Also I would like to keep 4 weeks full backups. After that one by one we need to delete the backup.
    For example, if I have 4 weeks fullbackup of February, after taking full backup for first week of March, the backup of first week of February should get deleted.
    Kindly help with your suggestions.
    Thanks & Regards,
    Rafnas

    Hi,
    Thank you for pointing to the blog. It was very much useful.
    I was testing the backup strategy using your script. It worked fine for first set of daily backups.
    After weekly backup is taken, the daily backup script fails for taking the backup from next day onwards.
    It gives the following error stack.
    Starting backup at 05-MAR-09
    using channel ORA_DISK_1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 03/05/2009 01:47:55
    ORA-01455: converting column overflows integer datatype
    Could you please let me know why integer datatype comes into picture while taking backup?
    Please advice.
    Thanks & Regards,
    Rafnas
    Edited by: user10698483 on Mar 5, 2009 3:38 AM

  • Schedule the daily backup from Monday to Saturday?

    Dear all,
    I am the first time to scheduling the daily backup, I have following questions:
    1) My daily backup scripts in what format? for example: in sh format
    Run
         CONFIGURE CONTROLFILE AUTOBACKUP ON;
         CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
         allocate channel ch1 type disk format '/u02/db/backup/RMAN/backup_%d_%t_%s_%p_%U.bck';
         backup incremental level 1 cumulative database plus archivelog delete all input;
         delete noprompt obsolete;
         delete noprompt archivelog all backed up 2 times to disk;
         backup current controlfile;
         backup spfile;
         release channel ch1;
    2) I am not familiar with to using schedule job, I know following structure.
    Minute hour [Day of Month] [Month] [Day of Week]
    Minute (0)
    Hour (24)
    Day of month (??)
    Month (every month)
    Day of week (0-6) 0 = Sunday, 1 = Monday, ... or Sun, Mon, etc)
    Command to execute (how to execute the command)
    Best Regards,
    Amy

    Hi,
    Firstly, if you are using recovery catalog, then create rman scripts and In case you dont have recobery catalog, then add the backup script in the .sh file .
    Then create .sh file and not to forget add environment variable for oracle in that .sh file.
    Then schedule that file with cron and format you know for the cron.
    Make sure cron is started on the machine.
    Example for .sh file is
    export ORACLE_SID=<ORACLE_SID>
    export path=<ORACLE_PATH>
    rman<<EOF
    connect target sys/<password
    run{
    body
    but the best way is to go for rman backup scripts using recobery catalog
    THanks,
    Navneet

  • Need Advice on RMAN backup script

    Hi;
    Can any one advice if any error or guide to make RMAN backup proper :
    Backup Policy are:
    1.     0 level backup
    2.     current log file is arvhived before backing up
    3.     backup whole database (datafiles)
    4.     backup separate control file
    5.     backup is done on disk
    6.     control file auto backup ON
    7.     only 7 days archive log are need to be preserve ; old need to be deleted
    ### one time paramters seting
    RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;
    RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
    RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'O:\rman\backup\Auto_Ctrl_weekly_%F';
    RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
    ### Command for weekly 0 level backup
    run {
    allocate channel c1 type disk;
    sql 'alter system archive log current';
    backup incremental level 0 tag = weekly_database format 'o:\rman\backup\full_weekly_%d_%s_%p_%t'(database);
    release channel c1;
    configure controlfile autobackup format for device type disk to 'o:\rman\backup\auto_ctrl_weekly_%f';
    allocate channel c1 type disk;
    backup tag = weekly_arch archivelog until time 'sysdate-7' format 'o:\rman\backup\archive_weekly_%d_%s_%p_%t';
    delete archivelog until time 'sysdate-7';
    release channel c1;
    Regards
    Smith

    Dear Pierre F.;
    Actually, I just added in my backup plan to have daily backup through RMAN, instead of COLD backup.
    I have planned to take cold backup once a week. here is the side of data:
    *** datafile 410
    *** size of database : 86 GM
    *** relog files size : 250MB
    *** daily archive logs are : 250MB * 4(number of files) = 1GM aprox.
    yes, time constraint is there; just because of the size of database. and we r going for 24/7
    Is this script going to run only one per week ?
    Ans: no I this was level 0 backup; i will take level 1 incremental backup with same script daily too.
    Do you have any other RMAN script ?
    ANS: no, I will modify same script for incremental.
    after local copy of backup all backup files (RMAN) will be copy over network to backup server or we can install LTO tape device to copy directly from database server.
    kindly advise me I am new in RMAN.
    regards;
    SMITH

  • Daily backup on Ms sql server management  studio (MS sql 2005).

    I wander how to perform daily backup on Ms sql server management  studio (MS sql 2005).
    In sql server  Entereprise manager (MS sql 2000) I had no problem to shedule.
    But now I do not find this option

    Hi
    Please follow these steps in SQL Server Management Studio in SQL Server 2005 and <b>award points</b>
    1. Start SQL Server Management Studio.
    2. In the Connect to Server dialog box, click the appropriate values in the Server type list, in the Server name list, and in the Authentication list. 
    3. Click Connect.
    4. In Object Explorer, expand Databases.
    5. Right-click the database that you want to back up, click Tasks, and then click Back Up.
    6. In the Back Up Database - DatabaseName dialog box, type the name of the backup set in the Name box, and then click Add under Destination.
    7. In the Select Backup Destination dialog box, type a path and a file name in the Destinations on disk box, and then click OK.
    8. In the Script list, click Script Action to Job.
    9. In the New Job dialog box, click Steps under Select a page, and then click Edit if you want to change the job parameters.
    Note In the Job Step Properties - 1 dialog box, you can see the backup command.
    10. Under Select a page, click Schedules, and then click New.
    11. In the New Job Schedule dialog box, type the job name in the Name box, specify the job schedule, and then click OK.
    Note If you want to configure alerts or notifications, you can click Alerts or Notifications under Select a page.
    12. Click OK two times.
    You receive the following message:
    The backup of database 'DatabaseName' completed successfully.
    Note To verify the backup job, expand SQL Server Agent, and then expand Jobs. When you do this, the SQL Server Agent service must be running.

  • MS SQL Server 2008 -- Daily Backup

    Hello,
    My real need is simply to do a daily backup of a database : I have SQL Server 2008
    ( not express ) .
    My user is    sa       and has full control on the database.
    I have searched the web and found many places where they say to do a     Task -> Backup    and then click on "script action to job". This option is greyed out ( and it is NOT express) and I am using the   sa    
    user will FULL privileges.
    I read here ( http://social.msdn.microsoft.com/Forums/sqlserver/en-US/4c5b5ff3-f2cd-4439-b878-de0891a5eedf/sql-server-management-studio-express-script-action-to-job-grayed-out?forum=sqldatabaseengine )  that I may need to    "Install
    Integration Services"   .   
    However, when I go to do this  (
    http://msdn.microsoft.com/en-us/library/ms143731(v=sql.105).aspx ) , I read:
    You can install SQL Server Integration Services on a computer that has no previous instances of SQL Server.
    Well, my server is already installed and running in production. 
    Q: can I "Install Integration Services" even if I have an SQL server installed and running ?
    Q: do I absolutely require to have Integration Services to automate the backups?
    Q: any simple way to just dump the database every night to a folder ?
    Thanks!
    Johnny

    You can use the Database Maintenance Wizard to setup a daily backup job.
    BOL: "Use the Maintenance Plan Wizard
    This topic describes how to create a single server or multiserver maintenance plan using the Maintenance Plan Wizard in SQL Server 2014. The Maintenance Plan Wizard creates a maintenance plan that Microsoft SQL Server Agent can run on a regular basis. This
    allows you to perform various database administration tasks, including backups, database integrity checks, or database statistics updates, at specified intervals."
    LINK: http://msdn.microsoft.com/en-us/library/ms191002.aspx
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Rman hot backup script  gives error in R12.

    hi 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.
    [root@testerp rman_log]# cat UAT_daily_rman_hot_bkp_01-11-14_140301.log
    -bash: /root/.bash_profile: Permission denied
    Recovery Manager: Release 11.1.0.7.0 - Production on Sat Jan 11 14:03:01 2014
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    connected to target database: UAT (DBID=2855851979)
    connected to recovery catalog database
    RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12>
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "end-of-file": expecting one of: "allocate, alter, advise, backup, beginline, blockrecover, catalog, change, copy, convert, crosscheck, configure, duplicate, debug, delete, execute, endinline, flashback, host, mount, open, plsql, recover, release, replicate, report, restore, resync, repair, }, set, setlimit, sql, switch, startup, shutdown, send, show, transport, validate"
    RMAN-01007: at line 12 column 1 file: standard input
    RMAN>
    RMAN>
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "identifier": expecting one of: "for"
    RMAN-01008: the bad identifier was: c2
    RMAN-01007: at line 1 column 18 file: standard input
    RMAN>
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "identifier": expecting one of: "for"
    RMAN-01008: the bad identifier was: c3
    RMAN-01007: at line 1 column 18 file: standard input
    RMAN>
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "identifier": expecting one of: "for"
    RMAN-01008: the bad identifier was: c4
    RMAN-01007: at line 1 column 18 file: standard input
    RMAN>
    Starting backup at 11-JAN-14
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=362 device type=DISK
    channel ORA_DISK_1: starting incremental level 1 datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00021 name=/d06/UAT/proddata/a_txn_data06.dbf
    input datafile file number=00392 name=/d06/UAT/db/apps_st/data/a_txn_data01.dbf
    input datafile file number=00401 name=/d06/UAT/db/apps_st/data/a_txn_data02.dbf
    input datafile file number=00402 name=/d06/UAT/db/apps_st/data/a_txn_data03.dbf
    input datafile file number=00022 name=/d06/UAT/proddata/a_txn_data07.dbf
    input datafile file number=00014 name=/d06/UAT/db/apps_st/data/a_txn_data04.dbf
    input datafile file number=00020 name=/d06/UAT/proddata/a_txn_data05.dbf
    input datafile file number=00011 name=/d06/UAT/db/apps_st/data/sysaux01.dbf
    input datafile file number=00018 name=/d06/UAT/db/apps_st/data/sysaux02.dbf
    input datafile file number=00023 name=/d06/UAT/proddata/a_txn_data08.dbf
    input datafile file number=00379 name=/d06/UAT/db/apps_st/data/undo01.dbf
    input datafile file number=00024 name=/d06/UAT/proddata/sysaux03.dbf
    input datafile file number=00025 name=/d06/UAT/proddata/sysaux04.dbf
    input datafile file number=00033 name=/d06/UAT/proddata/a_txn_ind11.dbf
    input datafile file number=00029 name=/d06/UAT/proddata/a_txn_ind09.dbf
    input datafile file number=00030 name=/d06/UAT/proddata/a_txn_ind10.dbf
    input datafile file number=00015 name=/d06/UAT/db/apps_st/data/a_txn_ind06.dbf
    input datafile file number=00026 name=/d06/UAT/db/apps_st/data/a_txn_ind07.dbf
    input datafile file number=00028 name=/d06/UAT/db/apps_st/data/a_txn_ind08.dbf
    input datafile file number=00393 name=/d06/UAT/db/apps_st/data/a_txn_ind01.dbf
    input datafile file number=00403 name=/d06/UAT/db/apps_st/data/a_txn_ind02.dbf
    input datafile file number=00404 name=/d06/UAT/db/apps_st/data/a_txn_ind03.dbf
    input datafile file number=00405 name=/d06/UAT/db/apps_st/data/a_txn_ind04.dbf
    input datafile file number=00406 name=/d06/UAT/db/apps_st/data/a_txn_ind05.dbf
    input datafile file number=00400 name=/d06/UAT/db/apps_st/data/a_media01.dbf
    input datafile file number=00353 name=/d06/UAT/db/apps_st/data/system08.dbf
    input datafile file number=00013 name=/d06/UAT/db/apps_st/data/system12.dbf
    input datafile file number=00352 name=/d06/UAT/db/apps_st/data/system09.dbf
    input datafile file number=00394 name=/d06/UAT/db/apps_st/data/a_ref01.dbf
    input datafile file number=00407 name=/d06/UAT/db/apps_st/data/a_ref02.dbf
    input datafile file number=00396 name=/d06/UAT/db/apps_st/data/a_summ01.dbf
    input datafile file number=00395 name=/d06/UAT/db/apps_st/data/a_int01.dbf
    input datafile file number=00008 name=/d06/UAT/db/apps_st/data/a_queue02.dbf
    input datafile file number=00027 name=/d06/UAT/db/apps_st/data/a_queue03.dbf
    input datafile file number=00031 name=/d06/UAT/db/apps_st/data/a_queue04.dbf
    input datafile file number=00399 name=/d06/UAT/db/apps_st/data/a_queue01.dbf
    input datafile file number=00001 name=/d06/UAT/db/apps_st/data/system01.dbf
    input datafile file number=00002 name=/d06/UAT/db/apps_st/data/system02.dbf
    input datafile file number=00003 name=/d06/UAT/db/apps_st/data/system03.dbf
    input datafile file number=00004 name=/d06/UAT/db/apps_st/data/system04.dbf
    input datafile file number=00005 name=/d06/UAT/db/apps_st/data/system05.dbf
    input datafile file number=00398 name=/d06/UAT/db/apps_st/data/a_archive01.dbf
    input datafile file number=00295 name=/d06/UAT/db/apps_st/data/system06.dbf
    input datafile file number=00351 name=/d06/UAT/db/apps_st/data/system07.dbf
    input datafile file number=00354 name=/d06/UAT/db/apps_st/data/system11.dbf
    input datafile file number=00288 name=/d06/UAT/db/apps_st/data/system10.dbf
    input datafile file number=00012 name=/d06/UAT/db/apps_st/data/apps_ts_tools01.dbf
    input datafile file number=00016 name=/d06/UAT/db/apps_st/data/a_ref03.dbf
    input datafile file number=00019 name=/d06/UAT/db/apps_st/data/MLSEIGL01.dbf
    input datafile file number=00032 name=/d06/UAT/db/apps_st/data/RMAN01.dbf
    input datafile file number=00397 name=/d06/UAT/db/apps_st/data/a_nolog01.dbf
    input datafile file number=00314 name=/d06/UAT/db/apps_st/data/portal01.dbf
    input datafile file number=00017 name=/d06/UAT/db/apps_st/data/a_int02.dbf
    input datafile file number=00006 name=/d06/UAT/db/apps_st/data/ctxd01.dbf
    input datafile file number=00010 name=/d06/UAT/db/apps_st/data/olap.dbf
    input datafile file number=00009 name=/d06/UAT/db/apps_st/data/odm.dbf
    input datafile file number=00007 name=/d06/UAT/db/apps_st/data/owad01.dbf
    channel ORA_DISK_1: starting piece 1 at 11-JAN-14
    [root@testerp rman_log]#
    backup script is below:
    in this script it returns error only at the channel allocaition rest of all backup command i run manually or with scirpt it runs correctly.4
    i m not able to know why it returns error only at challnel allocation 1 day before it runs correctly.
    [orauat@testerp rman_script]$ cat rman_backup.sh
    #!/bin/sh
    #ORACLE_SID=UAT
    #BACKUP_START_TIME='date +"%y""%m""%d"_"%H""%M""%S"'
    #ORACLE_HOME=/d06/UAT/db/tech_st/11.1.0
    #PATH=$PATH:${ORACLE_HOME}:${ORACLE_HOME}/bin
    #export ORACLE_SID
    #export ORACLE_HOME
    #export PATH
    /d06/UAT/db/tech_st/11.1.0/bin/rman catalog rman/rman007 target sys/sysuat <<EOF
    run
    allocate channel c1 device type disk format '/d06/UAT/rman_hot_backup/Daily_backup%d_Arch_%c_%U';
    sql 'alter system switch logfile';
    sql 'alter system switch logfile';
    sql 'alter system archive log current';
    delete expired archivelog all;
    crosscheck archivelog all;
    backup archivelog all;
    delete noprompt archivelog all completed before 'sysdate-4' backed up 1 times to disk;
    allocate channel c2 device type disk format '/d06/UAT/rman_hot_backup/Daily_backup%d_DB_%c_%U';
    allocate channel c3 device type disk format '/d06/UAT/rman_hot_backup/Daily_backup%d_DB_%c_%U';
    allocate channel c4 device type disk format '/d06/UAT/rman_hot_backup/Daily_backup%d_DB_%c_%U';
    backup incremental level 1 database;
    delete expired backup device type disk;
    delete obsolete device type disk;
    release channel c1;
    release channel c2;
    release channel c3;
    release channel c4;
    exit
    EOF
    regards
    pritesh ranjan

    yes the script is edited
    i have add some command line and edit it for take the full backup level=0 on the same directory with different formant name but location is same.
    can i take full backup level 0 and incremental backup level 1 in the same directory with the different format name.
    for exp:
    allocate channel c2 device type disk format '/d06/UAT/rman_hot_backup/Daily_backup%d_DB_%c_%U';
    allocate channel c3 device type disk format '/d06/UAT/rman_hot_backup/Daily_backup%d_DB_%c_%U';
    allocate channel c4 device type disk format '/d06/UAT/rman_hot_backup/Daily_backup%d_DB_%c_%U';
    i allocate these three channel for incremental level 1 backup;
    the backup is done successfully without any error.
    after that i have change
    allocate channel c2 device type disk format '/d06/UAT/rman_hot_backup/Weekly_backup%d_DB_%c_%U';
    allocate channel c3 device type disk format '/d06/UAT/rman_hot_backup/Weekly_backup%d_DB_%c_%U';
    allocate channel c4 device type disk format '/d06/UAT/rman_hot_backup/Weekly_backup%d_DB_%c_%U';
    backup  database incremental level 0
    after doing the above changes it get the error. with the channel location.
    i have to schedule daily incremental backup level 1 and weekly full backup level 0.
    plz suggest me i have to take incremental 1 and full incremental level 0 backup on seperate directory for different format name.
    regards
    pritesh ranjan

  • Daily Backup

    Dear all ,
    Today i am first time implementing daily backup for oracle 10g on rehl5.5. I completed RMAN Configuration.
    Now I made script for daily backup in which i include RMAN commands and this commands run successfully in RMAN according to my requirement.
    The problem is i don 't know how to run this dbackup.sh file using crontab.
    So please guide me how i can execute this file on daily basis.
    Thanks in advance
    Edited by: abdul moyed on Feb 27, 2012 4:35 PM

    Hello;
    To run daily at 4PM
    00 16 * * 0-6 /u01/app/oracle/dba_tool/PRIMARY/db_rman_full.sh > /tmp/PRIMARY_rmanfull.outThe top of my script call an "env" which is needed for the crontab otherwise the script will fail
    #!/bin/bash
    # Name: db_rman_full.sh
    # Purpose: Database rman backup
    # Usage : db_rman_full <DBNAME>
    . /u01/app/oracle/dba_tool/env/PRIMARY.env
    echo "Starting RMAN..."
    $ORACLE_HOME/bin/rman target / catalog <user>/<password>@catalogdb <<EOF/u01/app/oracle/dba_tool/env/PRIMARY.env ( looks likes )
    ORACLE_BASE=/u01/app/oracle
    ULIMIT=unlimited
    ORACLE_SID=PRIMARY
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0.2
    ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    LIBPATH=$LD_LIBRARY_PATH:/usr/lib
    TNS_ADMIN=$ORACLE_HOME/network/admin
    PATH=$ORACLE_HOME/bin:$ORACLE_BASE/dba_tool/bin:/bin:/usr/bin:/usr/ccs/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/lbin:/GNU/bin/make:/u01/app/oracle/dba_tool/bin:/home/oracle/utils/SCRIPTS:/usr/local/bin:.
    export TERM=vt100
    export ORACLE_BASE ORACLE_SID ORACLE_TERM ULIMIT
    export ORACLE_HOME
    export LIBPATH LD_LIBRARY_PATH ORA_NLS33
    export TNS_ADMIN
    export PATHChange as need for your setup.
    Please consider closing some of your old questions to keep the forum clean.
    Best Regards
    mseberg

  • Schedule Daily backup error

    Dear all,
    Here is the error message in daily backup log file:
    ===================================================================
    Backup Set 302 25-SEP-08
    Backup Piece 302 25-SEP-08 /u02/db/backup/RMAN/backup_UAT_666356697_324_1_a4jrfiup_1_1.bck
    Controlfile Copy 2 18-AUG-08 /home/oracle/rsbackup/UAT/backup_control.ctl
    released channel: ch1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03009: failure of delete command on default channel at 10/03/2008 11:15:23
    ORA-19569: no device is allocated to this session
    Recovery Manager complete.
    =====================================================================
    Anything wrong? How can I solve this?
    Best Regards,
    Amy

    I get the following error message:
    RMAN> Run
    2> {
    3> CONFIGURE CONTROLFILE AUTOBACKUP ON;
    4> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    5> allocate channel ch1 type disk format '/u02/db/backup/RMAN/backup_%d_%t_%s_%p_%U.bck';
    6> backup incremental level 1 cumulative database plus archivelog delete all input;
    7> backup current controlfile;
    8> backup spfile;
    9> release channel ch1;
    10> allocate channel for
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01005: syntax error: found "for": expecting one of: "channel_id, double-quoted-string, identifier, single-quoted-string"
    RMAN-01007: at line 10 column 18 file: daily_backup_db.rmn
    -------------------- Here is the backup script -------------------------
    Run
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    allocate channel ch1 type disk format '/u02/db/backup/RMAN/backup_%d_%t_%s_%p_%U.bck';
    backup incremental level 1 cumulative database plus archivelog delete all input;
    backup current controlfile;
    backup spfile;
    release channel ch1;
    allocate channel for maintenance type disk;
    delete noprompt obsolete;
    delete noprompt archivelog all backed up 2 times to disk;
    Please advice,
    Amy

  • Help Needed With a Backup Script

    I 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 current month's backup (30 different copies/Folder of backup for each day)
    Create a folder every calender month and and copy all 30 copies of backups within this folder
    Email Results of copying process either success or failed
    So Far i have the following which covers half of what is required! 
    $date = Get-Date -Format yyyyMMdd
    New-Item C:\dnsbk\DNSBackup$date -ItemType Directory
    $1st = Export-DnsServerZone -Name test.ac.uk -Filename backup\test.ac.uk.bk
    $2nd = Export-DnsServerZone -Name _msdcs.test.ac.uk -FileName backup\_msdcs.test.ac.uk.bk
    $source = "C:\windows\system32\dns\*"
    $destination = "C:\dnsbk\DNSBackup$date"
    $copy = Copy-Item -Recurse $source $destination
    $successSubject = "Backup Completed Successfully"
    $SuccessBody = "$1st,$2nd,$copy" <<<<<< This does not work >>>>>
    Send-MailMessage -From "[email protected]" -To "[email protected]" -Subject $successSubject -SmtpServer 192.168.0.1 -Body $SuccessBody

    Hi IM3th0,
    If you want to confirm whether the copy operation run successfully and pass the result to the variable $SuccessBody, please try the script below:
    $copy = Copy-Item -Recurse $source $destination -PassThru -ErrorAction silentlyContinue
    if ($copy) { $SuccessBody="copy success" }
    else { $SuccessBody="Copy failure"}
    Reference from:
    how to capture 'copy-item' output
    If you want to remove the other 29 copies and keep the lastest one, please filter the 29 copies based on lastwritetime:
    $CLEANUP = (Get-DATE).AddDays(-30)
    $CLEANUP1 = (Get-DATE).AddDays(-1)
    Get-ChildItem | %{
    if($_.lastwritetime -gt $CLEANUP -and $_.lastwritetime -lt $CLEANUP1){
    Remove-Item $_.fullname -whatif}
    If I have any misunderstanding, please let me know.
    I hope this helps.

  • Time Machine making Daily backups of Entire Itunes Library

    Hi There,
    I have searched around the forums and cannot find an answer to my problem.
    I am using time machine over a 1TB time capsule, my laptop is the only computer that is backing up to the drive,
    Originally I noticed that my time machine backups were taking a long time (over 7 hours while connected through Ethernet)
    I have downloaded BackupLoupe and using this utility I have found that daily backups of my entire Itunes music Library are being made (122GB).
    Does anyone have any idea what may be causing this issue? I have followed the Time machine trouble shooting guide and Completely wiped the drive and started again,
    I have performed a disk and permission repair on both the time capsule drive and on the Macbook through the install DVD, however each time I initiate time machine on the freshly reconditioned drives it happens again.
    Any help would be greatly appreciated, I am going slowly insane.
    Cheers
    Josh

    bigjnz wrote:
    I have downloaded BackupLoupe and using this utility I have found that daily backups of my entire Itunes music Library are being made (122GB).
    Is it only the iTunes folder; and the entire contents?
    If so, the iTunes folder itself may be damaged. That happens occasionally; something in a folder object gets corrupted, and Time Machine either doesn't find real changes, or thinks everything changed.
    In those cases, the only solution we've been able to find is to rename the folder, create a new one, move the contents, and delete the old one. The first backup afterwards will back up everything, but thereafter it should be ok.

  • Backup script

    I 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 create a partial copy of 1 on 2, such that 2 would contain the entire system (bootable) + a part of my data.
    1. You need to have the same filesystem on both (i have ext4). Maybe it works with a mix of ext3 and 4, but it's better to have just one. The partitioning scheme on hdd 1 doesn't matter, but for hdd 2 you need a single partition to which you backup.
    2. The scripts:
    backup
    #!/bin/sh
    # rsync backup script
    sudo rsync -av --delete-excluded --exclude-from="excl" / "$1"
    sudo touch "$1"/BACKUP
    This one is very simple. You rsync in archive mode (which ensures that symbolic links, devices, attributes,  permissions,  ownerships,  etc.  are preserved) and exclude the files that match the patterns from excl.
    The / is the source from where you backup (in our case the whole root) and "$1" is the destination to where you backup (this is passed as an argument to the script).
    excl
    # Include
    + /dev/console
    + /dev/initctl
    + /dev/null
    + /dev/zero
    + /media/win
    + /var/run/mpd
    + /home/wooptoo/music/Amestecate
    + /home/wooptoo/music/script
    + /home/wooptoo/music/list.txt
    + /home/wooptoo/music/.hg*
    # Exclude
    - /home/wooptoo/dl/*
    - /home/wooptoo/games/kits/*
    - /home/wooptoo/mov/*
    - /home/wooptoo/music/*
    - /dev/*
    - /media/*
    - /media/win/*
    - /mnt/*
    - /proc/*
    - /sys/*
    - /tmp/*
    - /var/run/*
    - /var/run/mpd/*
    This is a bit more tricky. It's an exclude (and include) file in rsync format.
    Exclude: I excluded my games, movies and music from the backup, and also the system directories /dev, /media, /mnt, /proc, /sys, /tmp, /var/run. These are excluded because their content is created at runtime by the system. Note that the direcotries themselves are preserved (you need them!) but they are empty.
    Include: even though i excluded /dev, i need to include 4 file from it (which are not dinamically created by udev), these are console, initctl, null, zero.
    I also included the directories /media/win and /var/run/mpd. But these are empty, because their content was excluded (in the exclude section).
    3. So we got these two files: backup and excl.
    Mount the backup hdd, let's say at /media/backup/ and run the script:
    ./backup /media/backup/
    rsync will backup the whole root to that destination. I excluded game kits, music and movies from my backup because they are just too large to fit on hdd 2, and it would also take a lot of time to backup and keep in sync afterwards.
    4. After the sync is finished you need to install a boot loader on hdd2, so you can have a working copy of your system.
    Open the grub console and type in:
    root (hd1,0)
    setup (hd1)
    The root command tells grub where your system is installed (in this case hdd 2, first partition).
    Setup tells grub where to install the boot loader. In my example it is installed in the MBR of hdd 2.
    The problem here is that the boot loader installs correctly, but its menu entries are for the partitions of the main system, not the backup system. So if you'll try to boot the backup system, it won't work.
    You can fix this by creating a custom menu.lst for the backup hdd. But i prefer not to do this, in order to have an accurate copy of my data. I just prefer to edit the entries from the boot menu on the fly if i need to boot the backup directly. But you can automatically add a custom menu.lst to the backup hdd from the backup script:
    #!/bin/sh
    # rsync backup script
    sudo rsync -av --delete-excluded --exclude-from="excl" / "$1"
    sudo cp ~/custom.menu.lst "$1"/boot/grub/menu.lst
    sudo touch "$1"/BACKUP
    5. Reboot and try out your new system.
    I think this approach (system + data backup) is better than just data backup because if something goes wrong with the main hdd, you can always swap in the backup one and continue working. Besides this, you now have another working system, from which you can recover the main one without the need of live CDs.
    In my setup both hdds are SATA with AHCI, so they are hot-pluggable. You can plugin the backup drive, run the backup script, and disconnect it. This is very advantageous because you don't have to reboot.
    But you can use an USB stick/hdd as backup drive if you only have IDE.
    I would like to know what do you think of my backup strategy. Is it good or am i doing it wrong? Are there better methods? What backup strategy do you use? etc.
    Last edited by wooptoo (2009-10-24 01:40:46)

    I use the following to rotate four backups and backup my root and home separately and hard-link common files between all the backups. I run this weekly to have backups of the last four weeks while using barely more space then one full backup would. It is not super customisable as it is my personal script and I've been wanting to add in a check to see whether the backup location is actually mounted, but I've not gotten to it just yet
    #!/bin/bash
    # Script to rotate three backups of / and /home and make a new incremental
    # backup. No arguments required. Make sure the correct disk is mounted at
    # $PAR, though!
    # Original command ran to create the first backup of /home :
    # /usr/bin/sudo /usr/bin/rsync --progress --stats -avz \
    # --exclude-from=/home/ramses/home_backup_excludes --delete-exludes \
    # /home/ /media/seadisc/home_backup.0
    # Variables and paths
    PAR="/media/seadisc/backup"
    HOME_EXCLUDES="/usr/local/bin/backup_config/home_backup_excludes"
    ROOT_EXCLUDES="/usr/local/bin/backup_config/root_backup_excludes"
    SUDO="/usr/bin/sudo"
    MV="/bin/mv"
    RM="/bin/rm"
    RSYNC="/usr/bin/rsync"
    DATE="/bin/date"
    TEE="/usr/bin/tee"
    # Home backups
    echo "Moving previous /home backups ..."
    $SUDO $RM -rf $PAR/home_backup.3
    $SUDO $MV $PAR/home_backup.2 $PAR/home_backup.3
    $SUDO $MV $PAR/home_backup2_date $PAR/home_backup3_date
    $SUDO $MV $PAR/home_backup.1 $PAR/home_backup.2
    $SUDO $MV $PAR/home_backup1_date $PAR/home_backup2_date
    $SUDO $MV $PAR/home_backup.0 $PAR/home_backup.1
    $SUDO $MV $PAR/home_backup0_date $PAR/home_backup1_date
    echo "Doing incremental backup of /home ..."
    $SUDO $RSYNC --progress --stats -av \
    --exclude-from=${HOME_EXCLUDES} \
    --delete --delete-excluded \
    --link-dest=$PAR/home_backup.1 \
    /home/ $PAR/home_backup.0
    $SUDO $DATE | $TEE $PAR/home_backup0_date > /dev/null
    # Root backups
    echo "Moving previous / backups ..."
    $SUDO $RM -rf $PAR/root_backup.3
    $SUDO $MV $PAR/root_backup.2 $PAR/root_backup.3
    $SUDO $MV $PAR/root_backup2_date $PAR/root_backup3_date
    $SUDO $MV $PAR/root_backup.1 $PAR/root_backup.2
    $SUDO $MV $PAR/root_backup1_date $PAR/root_backup2_date
    $SUDO $MV $PAR/root_backup.0 $PAR/root_backup.1
    $SUDO $MV $PAR/root_backup0_date $PAR/root_backup1_date
    echo "Doing incremental backup of / ..."
    $SUDO $RSYNC --progress --stats -av \
    --exclude-from=${ROOT_EXCLUDES} \
    --delete --delete-excluded \
    --link-dest=$PAR/root_backup.1 \
    / $PAR/root_backup.0
    $SUDO $DATE | $TEE $PAR/root_backup0_date > /dev/null

  • How do I create a automated file backup script?

    I 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 Apple script or tell me how to do this?

    How are you backing up?   The Automator Calendar alarm should work.  Test with Automator first by creating a Workflow, then see if it works within Automator when you click "Run" 

  • Parallel Backup script written in python

    I'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 back up the system, home folder, and my documents folder to a set of multiple primary, secondary, and tertiary disks, respectively. The method is as follows:
    1. check for the existence of disks and create folders which will contain mountpoints for each category of disk.
    2. decrypt and mount disks found under subfolders within those category folders, creating the mountpoints if they don't exist.
    3. syncronize the aforementioned data to the mounted disks using rsync, doing all three classes of disk in parallel.
    4. unmount and close disks
    This is really my first serious python program, and I realize that it's a bit complicated. My code is rather sloppy, as well, perhaps understandably so given my novice status. My only other programming experience is with BASH scripts, but I digress.
    Here is the code for the script (about 250 lines). It is written as a series of functions, and I'm uncertain as to whether functions or objects would work better. Additionally, I'm sure there's a python function provided by the os module analogous to the sync system call, but I've yet to find it in my python desk reference. The backup functions need work, and I'm still trying to figure out how to get them to loop through the mounted disks in each folder and copy to them. I require assistance in determining how to write the backup functions to do as outlined above, and how to run them in parallel. This is still a work in progress, mind.
    #!/usr/bin/python
    # Backup Script
    #### preferences ####
    # set your primary/secondary backup disks, encryption, and keyfile (if applicable) here.
    # backup disks
    # primary and secondary backups. As used here,
    # primary backups refer to backups of the entire system made to an external drive
    # secondary backups refer to backups made of individual folders, such as documents
    # primary backup disks by UUID:
    global PDISKS
    PDISKS = ("/dev/disk/by-uuid/16d64026-28bd-4e1f-a452-74e76bb4d47b","")
    # secondary backups by UUID.
    global SDISKS
    SDISKS = ()
    # tertiary disks by UUID:
    global TDISKS
    TDISKS = ("/dev/disk/by-uuid/39543e6e-cf50-4416-9669-e97a6abd2a37","")
    # backup paths
    # these are the paths of the folders you wish to back up to secondary
    # and tertiary disks, respectively. Primary disks are set to back up the
    # contents of the root filesystem (/*). NO TRAILING SLASHES.
    global SBACKUP
    SBACKUP = "/home/bryant"
    global TBACKUP
    TBACKUP = "/home/bryant/docs"
    # use encryption:
    use_encryption = True
    # keyfile
    # set the full path to your keyfile here
    # this assumes a single keyfile for all backup disks
    # set this to None if you don't have a single keyfile for all of your backups
    keyfile = "/usr/local/bin/backup.keyfile"
    # import modules
    import os, subprocess, sys
    ### preliminary functions ###
    # these do the setup and post-copy work
    def check_dirs():
    """checks that the folders which contain the mountpoints exist, creates them if they don't"""
    print("checking for mountpoints...")
    p = os.path.isdir("/mnt/pbackup")
    if p == True:
    print("primary mountpoint exists.")
    elif p == False:
    print("mountpoint /mnt/pbackup does not exist.\n\tcreating...")
    os.mkdir("/mnt/pbackup")
    s = os.path.isdir("/mnt/sbackup")
    if s == True:
    print("secondary mountpoint exists.")
    elif s == False:
    print("mountpoint /mnt/pbackup does not exist.\n\tcreating...")
    os.mkdir("/mnt/sbackup")
    t = os.path.isdir("/mnt/tbackup")
    if t == True:
    print("tertiary mountpoint exists.")
    elif t == False:
    print("mountpoint /mnt/tbackup does not exist.\n\tcreating...")
    os.mkdir("/mnt/tbackup")
    def mount_disks():
    """mounts available backup disks in their respective subdirectories"""
    pfolder = 1
    sfolder = 1
    tfolder = 1
    pmapper = "pbackup" + str(pfolder)
    smapper = "sbackup" + str(sfolder)
    tmapper = "tbackup" + str(tfolder)
    for pdisk in PDISKS:
    e = os.path.islink(pdisk)
    if e == True:
    subprocess.call("sync",shell=True)
    kf=os.path.isfile(keyfile)
    if kf == True:
    print("keyfile found. Using keyfile to decrypt...")
    subprocess.call("sudo cryptsetup luksOpen " + pdisk + " " + pmapper + " --key-file " + keyfile,shell=True)
    if kf == False:
    print("keyfile not found or keyfile not set. \t\nAsking for passphrase...")
    subprocess.call("sudo cryptsetup luksOpen " + pdisk + " " + pmapper,shell=True)
    f = os.path.isdir("/mnt/pbackup/pbak" + str(pfolder))
    if f == True:
    subprocess.call("mount " + "/dev/mapper/" + pmapper + " /mnt/pbak" + str(pfolder),shell=True)
    pfolder += 1
    elif f == False:
    os.mkdir("/mnt/pbackup/pbak" + str(pfolder))
    subprocess.call("mount " + "/dev/mapper/" + pmapper + " /mnt/pbak" + str(pfolder),shell=True)
    pfolder += 1
    for sdisk in SDISKS:
    e = os.path.islink(sdisk)
    if e == True:
    subprocess.call("sync",shell=True)
    kf=os.path.isfile(keyfile)
    if kf == True:
    print("keyfile found. Using keyfile to decrypt...")
    subprocess.call("sudo cryptsetup luksOpen " + sdisk + " " + smapper + " --key-file " + keyfile,shell=True)
    if kf == False:
    print("keyfile not found or keyfile not set. \t\nAsking for passphrase...")
    subprocess.call("sudo cryptsetup luksOpen " + sdisk + " " + smapper,shell=True)
    f = os.path.isdir("/mnt/sbackup/sbak" + str(sfolder))
    if f == True:
    subprocess.call("mount " + "/dev/mapper/" + smapper + " /mnt/sbackup/sbak" + str(sfolder),shell=True)
    sfolder += 1
    elif f == False:
    os.mkdir("/mnt/sbackup/sbak" + str(folder))
    subprocess.call("mount " + "/dev/mapper/" + smapper + " /mnt/sbackup/sbak" + str(sfolder),shell=True)
    sfolder += 1
    for tdisk in TDISKS:
    e = os.path.islink(tdisk)
    if e == True:
    subprocess.call("sync",shell=True)
    kf=os.path.isfile(keyfile)
    if kf == True:
    print("keyfile found. Using keyfile to decrypt...")
    subprocess.call("sudo cryptsetup luksOpen " + tdisk + " " + tmapper + " --key-file " + keyfile,shell=True)
    if kf == False:
    print("keyfile not found or keyfile not set. \t\nAsking for passphrase...")
    subprocess.call("sudo cryptsetup luksOpen " + tdisk + " " + tmapper,shell=True)
    f = os.path.isdir("/mnt/tbackup/tbak" + str(tfolder))
    if f == True:
    subprocess.call("mount " + "/dev/mapper/" + tmapper + " /mnt/pbak" + str(tfolder),shell=True)
    tfolder += 1
    elif f == False:
    os.mkdir("/mnt/tbackup/tbak" + str(tfolder))
    subprocess.call("mount " + "/dev/mapper/" + tmapper + " /mnt/tbak" + str(tfolder),shell=True)
    tfolder += 1
    def umount_disks():
    """unmounts and relocks disks"""
    subprocess.call("umount /mnt/pbackup*",shell=True)
    subprocess.call("umount /mnt/sbackup*",shell=True)
    subprocess.call("umount /mnt/tbackup*",shell=True)
    subprocess.call("cryptsetup luksClose /dev/mapper/pbackup*",shell=True)
    subprocess.call("cryptsetup luksClose /dev/mapper/sbackup*",shell=True)
    subprocess.call("cryptsetup luksClose /dev/mapper/tbackup*",shell=True)
    def check_disks():
    """checks to see how many disks exist, exits program if none are attached"""
    pdisknum = 0
    sdisknum = 0
    tdisknum = 0
    for pdisk in PDISKS:
    p = os.path.islink(pdisk)
    if p == True:
    pdisknum += 1
    elif p == False:
    print("disk " + pdisk + " not detected.")
    for sdisk in SDISKS:
    s = os.path.islink(sdisk)
    if s == True:
    sdisknum += 1
    elif s == False:
    print("disk " + sdisk + " not detected.")
    for tdisk in TDISKS:
    t = os.path.islink(tdisk)
    if t == True:
    tdisknum += 1
    elif t == False:
    print("disk " + tdisk + " not detected.")
    total = pdisknum + sdisknum + tdisknum
    if total == 0:
    print("ERROR: no disks detected.")
    sys.exit()
    elif total > 0:
    print("found " + str(total) + " attached backup disks")
    print(str(pdisknum) + " Primary")
    print(str(sdisknum) + " secondary")
    print(str(tdisknum) + " tertiary")
    return total, pdisknum, sdisknum, tdisknum
    ### backup functions ###
    # these need serious work. Need to get them to loop through available mounted
    # disks in their categories and then execute rsync
    def pbackup():
    """calls rsync to backup the entire system to all pdisks"""
    dirs = os.listdir("/mnt/pbackup")
    for dir in dirs:
    m = os.path.ismount(dir)
    if m == True:
    subprocess.call("sync",shell=True)
    print("syncing disks with rsync...")
    # subprocess.call("rsync --progress --human-readable --numeric-ids --inplace --verbose --archive --delete-after --hard-links --xattrs --delete --compress --skip-compress={*.jpg,*.bz2,*.gz,*.tar,*.tar.gz,*.ogg,*.mp3,*.tar.xz,*.avi} /* /mnt/pbackup/" + dir + "/ --exclude={/sys/*,/mnt/*,/proc/*,/dev/*,/lost+found,/media/*,/tmp/*,/home/*/.gvfs/*,/home/*/downloads/*,/opt/*,/run/*",shell=True)
    print("test1")
    subprocess.call("sync",shell=True)
    print("disk synced with disk " + pdisk + ".")
    print("sync with disk " + pdisk + " complete.")
    elif m == False:
    continue
    def sbackup():
    """calls rsync to backup everything under SBACKUP folder to all sdisks"""
    dirs = os.listdir("/mnt/sbackup")
    for dir in dirs:
    m = os.path.ismount(dir)
    if m == True:
    subprocess.call("sync",shell=True)
    # subprocess.call("rsync --progress --human-readable --numeric-ids --inplace --verbose --archive --delete-after --hard-links --xattrs --delete --compress --skip-compress={*.jpg,*.bz2,*.gz,*.tar,*.tar.gz,*.ogg,*.mp3,*.tar.xz,*.avi} SBACKUP/* /mnt/sbackup/" + dir + "/",shell=True)
    print("test2")
    subprocess.call("sync",shell=True)
    print("disk synced with disk " + pdisk + ".")
    print("sync with disk " + sdisk + " complete.")
    elif m == False:
    continue
    def tbackup():
    """calls rsync to backup everything under TBACKUP folder to all tdisks"""
    dirs = os.listdir("/mnt/tbackup")
    for dir in dirs:
    m = os.path.ismount(dir)
    if m == True:
    subprocess.call("sync",shell=True)
    # subprocess.call("rsync --progress --human-readable --numeric-ids --inplace --verbose --archive --delete-after --hard-links --xattrs --delete --compress --skip-compress={*.jpg,*.bz2,*.gz,*.tar,*.tar.gz,*.ogg,*.mp3,*.tar.xz,*.avi} TBACKUP/* /mnt/sbackup/" + dir + "/",shell=True)
    print("test3")
    subprocess.call("sync",shell=True)
    print("disk synced with disk " + pdisk + ".")
    print("sync with disk " + sdisk + " complete.")
    elif m == False:
    continue
    #### main ####
    # check for root access:
    r=os.getuid()
    if r != 0:
    print("ERROR: script not run as root.\n\tThis script MUST be run as root user.")
    sys.exit()
    elif r == 0:
    # program body
    check_dirs()
    check_disks()
    mount_disks()
    # pbackup()
    # sbackup()
    tbackup()
    umount_disks()
    print("backup process complete.")
    Last edited by ParanoidAndroid (2013-08-07 20:01:07)

    I've run into a problem on line 149. I'm asking the program to list the directories under the top-level backup directories under /mnt, check to see if each one is a mountpoint, and if it is unmount it. It does this, but it appears to recurse into the directories under the directories I'm asking it to check. The output is:
    checking for mountpoints...
    primary mountpoint exists.
    secondary mountpoint exists.
    tertiary mountpoint exists.
    disk /dev/disk/by-uuid/16d64026-28bd-4e1f-a452-74e76bb4d47b not detected.
    found 1 attached backup disks
    0 Primary
    0 secondary
    1 tertiary
    keyfile found. Using keyfile to decrypt...
    mounting tbackup1 at /mnt/tbak1
    test3
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    not a mountpoint
    Device /dev/mapper/pbackup* is not active.
    Device /dev/mapper/sbackup* is not active.
    backup process complete.
    here is the code for the entire script. It's been much modified from the previously posted version, so I included all of the code versus the section in question for reference. As I said, the section that seems to be causing the issue is on line 149.
    #!/usr/bin/python
    # Backup Script
    #### preferences ####
    # set your primary/secondary backup disks, encryption, and keyfile (if applicable) here.
    # backup disks
    # primary and secondary backups. As used here,
    # primary backups refer to backups of the entire system made to an external drive
    # secondary backups refer to backups made of individual folders, such as documents
    # primary backup disks by UUID:
    global PDISKS
    PDISKS = ["/dev/disk/by-uuid/16d64026-28bd-4e1f-a452-74e76bb4d47b"]
    # secondary backups by UUID.
    global SDISKS
    SDISKS = []
    # tertiary disks by UUID:
    global TDISKS
    TDISKS = ["/dev/disk/by-uuid/39543e6e-cf50-4416-9669-e97a6abd2a37"]
    # backup paths
    # these are the paths of the folders you wish to back up to secondary
    # and tertiary disks, respectively. Primary disks are set to back up the
    # contents of the root filesystem (/*). NO TRAILING SLASHES.
    global SBACKUP
    SBACKUP = "/home/bryant"
    global TBACKUP
    TBACKUP = "/home/bryant/docs"
    # use encryption:
    use_encryption = True
    # keyfile
    # set the full path to your keyfile here
    # this assumes a single keyfile for all backup disks
    # set this to None if you don't have a single keyfile for all of your backups
    keyfile = "/usr/local/bin/backup.keyfile"
    # import modules
    import os, subprocess, sys
    ### preliminary functions ###
    # these do the setup and post-copy work
    def check_dirs():
    """checks that the folders which contain the mountpoints exist, creates them if they don't"""
    print("checking for mountpoints...")
    if os.path.isdir("/mnt/pbackup"):
    print("primary mountpoint exists.")
    else:
    print("mountpoint /mnt/pbackup does not exist.\n\tcreating...")
    os.mkdir("/mnt/pbackup")
    if os.path.isdir("/mnt/sbackup"):
    print("secondary mountpoint exists.")
    else:
    print("mountpoint /mnt/pbackup does not exist.\n\tcreating...")
    os.mkdir("/mnt/sbackup")
    if os.path.isdir("/mnt/tbackup"):
    print("tertiary mountpoint exists.")
    else:
    print("mountpoint /mnt/tbackup does not exist.\n\tcreating...")
    os.mkdir("/mnt/tbackup")
    def mount_disks(wdisk):
    """mounts available backup disks in their respective subdirectories"""
    pfolder = 1
    sfolder = 1
    tfolder = 1
    pmapper = "pbackup"
    smapper = "sbackup"
    tmapper = "tbackup"
    if wdisk == "p":
    for pdisk in PDISKS:
    if os.path.islink(pdisk):
    subprocess.call("sync",shell=True)
    if os.path.isfile(keyfile):
    print("keyfile found. Using keyfile to decrypt...")
    subprocess.call("sudo cryptsetup luksOpen " + pdisk + " " + pmapper + str(pfolder) + " --key-file " + keyfile,shell=True)
    else:
    print("keyfile not found or keyfile not set. \t\nAsking for passphrase...")
    subprocess.call("sudo cryptsetup luksOpen " + pdisk + " " + pmapper + str(pfolder),shell=True)
    if os.path.isdir("/mnt/pbackup/pbak" + str(pfolder)):
    print("mounting " + pmapper + str(pfolder) + " at /mnt/pbak" + str(pfolder))
    subprocess.call("mount " + "/dev/mapper/" + pmapper + str(pfolder) + " /mnt/pbackup/pbak" + str(pfolder),shell=True)
    pfolder += 1
    else:
    os.mkdir("/mnt/pbackup/pbak" + str(pfolder))
    subprocess.call("mount " + "/dev/mapper/" + pmapper + str(pfolder) + " /mnt/pbackup/pbak" + str(pfolder),shell=True)
    pfolder += 1
    elif wdisk == "s":
    for sdisk in SDISKS:
    if os.path.islink(sdisk):
    subprocess.call("sync",shell=True)
    if os.path.isfile(keyfile):
    print("keyfile found. Using keyfile to decrypt...")
    subprocess.call("sudo cryptsetup luksOpen " + sdisk + " " + smapper + str(sfolder) + " --key-file " + keyfile,shell=True)
    else:
    print("keyfile not found or keyfile not set. \t\nAsking for passphrase...")
    subprocess.call("sudo cryptsetup luksOpen " + sdisk + " " + smapper + str(sfolder),shell=True)
    if os.path.isdir("/mnt/sbackup/sbak" + str(sfolder)):
    print("mounting " + smapper + str(sfolder) + " at /mnt/sbak" + str(sfolder))
    subprocess.call("mount " + "/dev/mapper/" + smapper + str(sfolder) + " /mnt/sbackup/sbak" + str(sfolder),shell=True)
    sfolder += 1
    else:
    os.mkdir("/mnt/sbackup/sbak" + str(folder))
    subprocess.call("mount " + "/dev/mapper/" + smapper + str(sfolder) + " /mnt/sbackup/sbak" + str(sfolder),shell=True)
    sfolder += 1
    elif wdisk == "t":
    for tdisk in TDISKS:
    if os.path.islink(tdisk):
    subprocess.call("sync",shell=True)
    if os.path.isfile(keyfile):
    print("keyfile found. Using keyfile to decrypt...")
    subprocess.call("sudo cryptsetup luksOpen " + tdisk + " " + tmapper + str(tfolder) + " --key-file " + keyfile,shell=True)
    else:
    print("keyfile not found or keyfile not set. \t\nAsking for passphrase...")
    subprocess.call("sudo cryptsetup luksOpen " + tdisk + " " + tmapper + str(tfolder),shell=True)
    if os.path.isdir("/mnt/tbackup/tbak" + str(tfolder)):
    print("mounting " + tmapper + str(tfolder) + " at /mnt/tbak" + str(tfolder))
    subprocess.call("mount " + "/dev/mapper/" + tmapper + str(tfolder) + " /mnt/tbackup/tbak" + str(tfolder),shell=True)
    if os.path.islink(tdisk):
    tfolder += 1
    else:
    os.mkdir("/mnt/tbackup/tbak" + str(tfolder))
    subprocess.call("mount " + "/dev/mapper/" + tmapper + " /mnt/tbackup/tbak" + str(tfolder),shell=True)
    tfolder += 1
    def umount_disks():
    """unmounts and relocks disks"""
    pdirs = os.listdir("/mnt/pbackup")
    sdirs = os.listdir("/mnt/sbackup")
    tdirs = os.listdir("/mnt/tbackup")
    for pdir in pdirs:
    if os.path.ismount("/mnt/pbackup/" + pdir):
    subprocess.call("umount /mnt/pbackup/" + pdir,shell=True)
    else:
    print("not a mountpoint")
    for sdir in sdirs:
    if os.path.ismount("/mnt/sbackup/" + sdir):
    subprocess.call("umount /mnt/sbackup/" + sdir,shell=True)
    else:
    print("not a mountpoint")
    for tdir in tdirs:
    if os.path.ismount("/mnt/tbackup/" + tdir):
    subprocess.call("umount /mnt/tbackup/" + tdir,shell=True)
    else:
    print("not a mountpoint")
    subprocess.call("cryptsetup luksClose /dev/mapper/pbackup*",shell=True)
    subprocess.call("cryptsetup luksClose /dev/mapper/sbackup*",shell=True)
    subprocess.call("cryptsetup luksClose /dev/mapper/tbackup*",shell=True)
    def check_disks():
    """checks to see how many disks exist, exits program if none are attached"""
    pdisknum = 0
    sdisknum = 0
    tdisknum = 0
    for pdisk in PDISKS:
    if os.path.islink(pdisk):
    pdisknum += 1
    else:
    print("\ndisk " + pdisk + " not detected.")
    for sdisk in SDISKS:
    if os.path.islink(sdisk):
    sdisknum += 1
    else:
    print("\ndisk " + sdisk + " not detected.")
    for tdisk in TDISKS:
    if os.path.islink(tdisk):
    tdisknum += 1
    else:
    print("\ndisk " + tdisk + " not detected.")
    total = pdisknum + sdisknum + tdisknum
    if total == 0:
    print("\nERROR: no disks detected.")
    sys.exit()
    elif total > 0:
    print("found " + str(total) + " attached backup disks")
    print(str(pdisknum) + " Primary")
    print(str(sdisknum) + " secondary")
    print(str(tdisknum) + " tertiary")
    return total, pdisknum, sdisknum, tdisknum
    ### backup functions ###
    # these need serious work. Need to get them to loop through available mounted
    # disks in their categories and then execute rsync
    def pbackup():
    """calls rsync to backup the entire system to all pdisks"""
    dirs = os.listdir("/mnt/pbackup")
    for dir in dirs:
    if os.path.ismount("/mnt/pbackup/" + dir) == True:
    subprocess.call("sync",shell=True)
    print("syncing disks with rsync...")
    subprocess.call("rsync --progress --human-readable --numeric-ids --inplace --verbose --archive --delete-after --hard-links --xattrs --delete --compress --skip-compress={*.jpg,*.bz2,*.gz,*.tar,*.tar.gz,*.ogg,*.mp3,*.tar.xz,*.avi} /* /mnt/pbackup/" + dir + "/ --exclude={/sys/*,/mnt/*,/proc/*,/dev/*,/lost+found,/media/*,/tmp/*,/home/*/.gvfs/*,/home/*/downloads/*,/opt/*,/run/*",shell=True)
    subprocess.call("sync",shell=True)
    else:
    continue
    def sbackup():
    """calls rsync to backup everything under SBACKUP folder to all sdisks"""
    dirs = os.listdir("/mnt/sbackup")
    for dir in dirs:
    if os.path.ismount("/mnt/sbackup/" + dir):
    subprocess.call("sync",shell=True)
    subprocess.call("rsync --progress --human-readable --numeric-ids --inplace --verbose --archive --delete-after --hard-links --xattrs --delete --compress --skip-compress={*.jpg,*.bz2,*.gz,*.tar,*.tar.gz,*.ogg,*.mp3,*.tar.xz,*.avi} " + SBACKUP + "/* /mnt/sbackup/" + dir + "/",shell=True)
    subprocess.call("sync",shell=True)
    else:
    continue
    def tbackup():
    """calls rsync to backup everything under TBACKUP folder to all tdisks"""
    dirs = os.listdir("/mnt/tbackup")
    for dir in dirs:
    if os.path.ismount("/mnt/tbackup/" + dir):
    subprocess.call("sync",shell=True)
    subprocess.call("rsync --progress --human-readable --numeric-ids --inplace --verbose --archive --delete-after --hard-links --xattrs --delete --compress --skip-compress={*.jpg,*.bz2,*.gz,*.tar,*.tar.gz,*.ogg,*.mp3,*.tar.xz,*.avi} " + TBACKUP + "/* /mnt/sbackup/" + dir + "/",shell=True)
    subprocess.call("sync",shell=True)
    else:
    continue
    #### main ####
    # check for root access:
    r=os.getuid()
    if r != 0:
    print("ERROR: script not run as root.\n\tThis script MUST be run as root user.")
    sys.exit()
    elif r == 0:
    # program body
    check_dirs()
    d=check_disks()
    if d[1] > 0:
    mount_disks("p")
    pbackup()
    elif d[2] > 0:
    mount_disks("s")
    sbackup()
    elif d[3] > 0:
    mount_disks("t")
    tbackup()
    umount_disks()
    print("backup process complete.")
    Last edited by ParanoidAndroid (2013-08-11 00:32:02)

  • Unix Backup Script Question

    Hello -
    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 the start time of the backup.
    Does anyone know how to do this in Unix?
    Any help is greatly appreciated!
    Thanks,
    Mike

    At the beginning of your backup use the touch command on a flag file of some kind. This will set the modified date to the current system time.
    At the end of your backup compare the modified time of the flag file to the other files. Something like:
    touch flag.file
    < do your backup >
    filelist=`ls filespec for files of interest`
    for f in $filelist
    do
       if [ $f -nt flag.test ]; then
          report it
       fi
    done[pre]
    HTH
    John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • Using Designer to get Document ID in Document Library

    I am creating an approval workflow on a document library that auto starts on submitting a document. What I want to do, besides sending the user a link to view the document, is to actually provide a link to the URL that is used to generated the popup

  • Importing Multiple Word Documents into RH

    I know that RH allows users to import word documents, however I was wondering if there was a way to import multiple word documents (ala batch style import) instead of importing each document one at a time.

  • Contact transfer to ipad

    Hello, I bought a new iPad air and wanted to transfer my contacts from my MBP ( Maverics installed ) to the new iPad via iTunes. When the iPad is connected I cannot find the box to select the option "transfer contacts". It is just not there. I have d

  • Can't Open PDF in Windows Live Mail

    I am having trouble opening a PDF file in Windows Live Mail that is sent to me. I can only open it if I save the file to desktop. I was able to open it just fine awhile ago. I don't know what I may have done. Can someone please help me. Thanks Mark

  • If i delete photos from my ipad will they be saved on my pc in iphoto?

    I need more space on my ipad.  If I delete photos on my ipad, will they be removed from my pc in iphoto?  I'm afraid to loose any pictures.