{"id":6054,"date":"2024-08-25T19:00:00","date_gmt":"2024-08-25T17:00:00","guid":{"rendered":"http:\/\/rootfan.com\/?p=6054"},"modified":"2024-08-25T23:04:50","modified_gmt":"2024-08-25T21:04:50","slug":"rman-script-para-tomar-copia-de-seguridad-completa-de-la-base-de-datos-mas-archivelog","status":"publish","type":"post","link":"https:\/\/rootfan.com\/es\/rman-script-to-take-full-database-backup-plus-archivelog\/","title":{"rendered":"Script de RMAN para realizar una copia de seguridad completa de la base de datos m\u00e1s Archivelog"},"content":{"rendered":"<p>Puede utilizar este script de RMAN para crear una copia de seguridad de una base de datos Oracle y guardarla en un destino especificado.<\/p>\n\n\n\n<p>Es importante que el BACKUP_BASE_PATH exista y que el ORACLE_SID sea reemplazado en el script.<\/p>\n\n\n\n<p>El script crear\u00e1 una carpeta dentro de BACKUP_BASE_PATH con el ORACLE_SID.<\/p>\n\n\n\n<!--more-->\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#!\/bin\/bash\n \n# Define backup base path\nBACKUP_BASE_PATH=&quot;\/home\/oracle\/backup&quot; # Replace this with your path\n\n# Provided Oracle SID\nexport ORACLE_SID=oradb # Replace this with your database SID\n\n# Determine the backup path for this specific Oracle SID\nBACKUP_PATH=&quot;${BACKUP_BASE_PATH}\/${ORACLE_SID}&quot;\n\n# Create the backup directory if it doesn&#039;t exist\nif &#x5B; ! -d &quot;$BACKUP_PATH&quot; ]; then\n    mkdir -p &quot;$BACKUP_PATH&quot;\n    if &#x5B; $? -ne 0 ]; then\n        echo &quot;Failed to create backup directory: $BACKUP_PATH&quot;\n        exit 1\n    fi\nfi\n\n# Automatically determine ORACLE_HOME based on ORACLE_SID from \/etc\/oratab\n# Assumes the oratab entry is in the format: &lt;sid&gt;:&lt;oracle_home&gt;:&lt;start_options&gt;\nexport ORACLE_HOME=$(grep &quot;^$ORACLE_SID:&quot; \/etc\/oratab | cut -d: -f2)\n \nif &#x5B; -z &quot;$ORACLE_HOME&quot; ]; then\n    echo &quot;ORACLE_HOME could not be determined from \/etc\/oratab&quot;\n    exit 1\nfi\n \nexport PATH=$ORACLE_HOME\/bin:$PATH\n \n# Define timestamp\nTIMESTAMP=$(date +%Y%m%d_%H%M%S) # Generates a timestamp in &#039;YYYYMMDD_HHMMSS&#039; format\n \n# Define tags based on ORACLE_SID\nDATABASE_TAG=&quot;${ORACLE_SID}_DB&quot;\nCONTROLFILE_TAG=&quot;${ORACLE_SID}_CTL&quot;\nSPFILE_TAG=&quot;${ORACLE_SID}_SPFILE&quot;\nARCHIVELOG_TAG=&quot;${ORACLE_SID}_ARC&quot;\n\n# Define the RMAN script file\nRMAN_SCRIPT=&quot;${BACKUP_BASE_PATH}\/rman_backup_${TIMESTAMP}.rcv&quot;\n\n# Define the log file\nLOG_FILE=&quot;${BACKUP_BASE_PATH}\/rman_backup_${TIMESTAMP}.log&quot;\n\n# Create the RMAN script file\ncat &lt;&lt;EOF &gt; ${RMAN_SCRIPT}\nRUN {\n    BACKUP AS COMPRESSED BACKUPSET\n    DATABASE TAG &#039;${DATABASE_TAG}&#039; FORMAT &#039;${BACKUP_PATH}\/${ORACLE_SID}_DB_${TIMESTAMP}_%U.bkp&#039;\n    CURRENT CONTROLFILE TAG &#039;${CONTROLFILE_TAG}&#039; FORMAT &#039;${BACKUP_PATH}\/${ORACLE_SID}_CTL_${TIMESTAMP}_%U.bkp&#039;\n    SPFILE TAG &#039;${SPFILE_TAG}&#039; FORMAT &#039;${BACKUP_PATH}\/${ORACLE_SID}_SPFILE_${TIMESTAMP}_%U.bkp&#039;\n    PLUS ARCHIVELOG TAG &#039;${ARCHIVELOG_TAG}&#039; FORMAT &#039;${BACKUP_PATH}\/${ORACLE_SID}_ARC_${TIMESTAMP}_%U.bkp&#039;;\n}\nEOF\n\n# Execute the RMAN script with nohup and tee to capture output in a log file\nnohup rman target \/ @${RMAN_SCRIPT} | tee ${LOG_FILE} &\n<\/pre><\/div>\n\n\n<p>Tambi\u00e9n puede a\u00f1adir estas 2 l\u00edneas al bloque de ejecuci\u00f3n si lo desea<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code\" data-no-translation=\"\"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nSQL &quot;ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS &#039;&#039;${BACKUP_PATH}\/controlfile_${TIMESTAMP}.trc&#039;&#039; &quot;;\nSQL &quot;CREATE PFILE=&#039;&#039;${BACKUP_PATH}\/init${ORACLE_SID}_${TIMESTAMP}.ora&#039;&#039; FROM SPFILE&quot;;\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Puede utilizar este script de RMAN para crear una copia de seguridad de una base de datos Oracle y guardarla en un destino especificado. Es importante que el BACKUP_BASE_PATH exista y que el ORACLE_SID sea reemplazado en el script. El script crear\u00e1 una carpeta dentro de BACKUP_BASE_PATH con el ORACLE_SID.<\/p>","protected":false},"author":1,"featured_media":6071,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_focus_keyword":"rman script to take full database backup","rank_math_title":"","rank_math_description":"Simplify your backup process with this RMAN script for taking a full database backup.","rank_math_robots":"","rank_math_og_title":"","rank_math_og_description":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[31],"tags":[78,92,93],"class_list":["post-6054","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oracle","tag-backup","tag-rman","tag-script"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/rootfan.com\/wp-content\/uploads\/pexels-photo-2531709-1.jpeg?fit=1862%2C1300&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/posts\/6054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/comments?post=6054"}],"version-history":[{"count":12,"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/posts\/6054\/revisions"}],"predecessor-version":[{"id":6216,"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/posts\/6054\/revisions\/6216"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/media\/6071"}],"wp:attachment":[{"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/media?parent=6054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/categories?post=6054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rootfan.com\/es\/wp-json\/wp\/v2\/tags?post=6054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}