{"id":1518,"date":"2025-06-17T06:29:41","date_gmt":"2025-06-17T06:29:41","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=1518"},"modified":"2025-06-17T06:43:46","modified_gmt":"2025-06-17T06:43:46","slug":"wordpress-auto-recovery-shell-script","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2025\/06\/17\/wordpress-auto-recovery-shell-script\/","title":{"rendered":"\uc6cc\ub4dc\ud504\ub808\uc2a4 \uc790\ub3d9 \ubcf5\uad6c \uc258 \uc2a4\ud06c\ub9bd\ud2b8 \/ WordPress Auto-Recovery Shell Script"},"content":{"rendered":"\n<p>\uad6c\uae00\ub4dc\ub77c\uc774\ube0c\/Google drive : <a href=\"https:\/\/drive.google.com\/drive\/folders\/1VeFCOlbkxh1ZsUmn6JPfpTSYC_Qj0v9e?usp=drive_link\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/drive.google.com\/drive\/folders\/1VeFCOlbkxh1ZsUmn6JPfpTSYC_Qj0v9e?usp=drive_link<\/a><\/p>\n\n\n\n<p>\ubc31\uc5c5\ub41c \uc6cc\ub4dc\ud504\ub808\uc2a4 \uc6f9\ud30c\uc77c\uacfc \ub370\uc774\ud130 \ubca0\uc774\uc2a4 \ud30c\uc77c\uc744 \uc790\ub3d9\ubcf5\uad6c\ud558\ub294 \uc258 \uc2a4\ud06c\ub9bd\ud2b8 \uc785\ub2c8\ub2e4.<br>This is a shell script that automatically restores backed up WordPress web files and database files.<\/p>\n\n\n\n<p>\uc218\ub3d9\uc73c\ub85c \uc258\uc2a4\ud06c\ub9bd\ud2b8\ub97c \uc2e4\ud589\ud574\ub3c4 \ub418\uace0 crontab\uc73c\ub85c \uc258\uc2a4\ud06c\ub9bd\ud2b8\ub97c \ud2b9\uc815\uc2dc\uac04\uc5d0 \uc790\ub3d9\uc2e4\ud589 \uc2dc\ud0ac \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br>You can run shell scripts manually or use crontab to automatically run shell scripts at specific times.<\/p>\n\n\n\n<p><strong>1.wp_restore_sample.sh<\/strong><\/p>\n\n\n\n<p>wp_restore_sample.sh\ud30c\uc77c\uc744 \uc5f4\uc5b4\uc11c \uc544\ub798\uc758 \uad75\uc740 \uae00\uc528\ubd80\ubd84\uc744 \uc218\uc815\ud569\ub2c8\ub2e4.<br>Open the wp_restore_sample.sh file and modify the bold text below.<\/p>\n\n\n\n<p>\uc124\uc815\ub0b4\uc6a9\uc740 \ubc18\ub4dc\uc2dc \uc11c\ubc84\uc640 \uc77c\uce58\ud574\uc57c \ud569\ub2c8\ub2e4.<br>The settings must match the server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># === \uc124\uc815 \/ Settings ===\n# \ubc31\uc5c5 \ud30c\uc77c\ub4e4\uc774 \uc800\uc7a5\ub420 \ub514\ub809\ud1a0\ub9ac (\uc808\ub300 \uacbd\ub85c)\n# \uc774 \ub514\ub809\ud1a0\ub9ac\uc5d0 tar.gz\uc640 sql\ud30c\uc77c\uc774 \uc788\uc5b4\uc57c \ud569\ub2c8\ub2e4.\n# Directory where backup files will be stored (absolute path)\n# There should be a tar.gz and sql file in this directory.\nBACKUP_DIR=\"<strong>\/home\/ubuntu\/backups<\/strong>\"\n\n# \uc6f9 \ud30c\uc77c\uc774 \uc124\uce58\ub420 \uc0c1\uc704 \ub514\ub809\ud1a0\ub9ac\n# Parent directory where web files will be installed\nWEB_ROOT=\"<strong>\/var\/www\/html<\/strong>\" \n\n# WordPress\uac00 \uc124\uce58\ub420 \ucd5c\uc885 \ub514\ub809\ud1a0\ub9ac \uc774\ub984 (\uc608: \/var\/www\/html\/wordpress) \n# The final directory name where WordPress will be installed (e.g. \/var\/www\/html\/wordpress)\nWP_DIR_NAME=\"<strong>wordpress<\/strong>\" \n\n# \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uacc4\uc815 \n# database account\nDB_NAME=\"<strong>your_db_name<\/strong>\" \nDB_USER=\"<strong>your_db_use<\/strong>r\" \nDB_PASSWORD=\"<strong>your_db_password<\/strong>\" \nDB_HOST=\"localhost\"\n\n# WP_ROOT_PATH\ub294 WordPress\uac00 \ucd5c\uc885\uc801\uc73c\ub85c \uc124\uce58\ub420 \uacbd\ub85c\uc785\ub2c8\ub2e4.\n# WP_ROOT_PATH is the path where WordPress will ultimately be installed.\nWP_ROOT_PATH=\"${WEB_ROOT}\/${WP_DIR_NAME}\"\n\n# \uc0c8\ub85c \ubcf5\uc0ac\ud560 wp-config.php \ud30c\uc77c\uc758 \uacbd\ub85c\n# \uc774 \ud30c\uc77c\uc5d0 \ub300\uc0c1 \uc11c\ubc84\uc758 DB \uc815\ubcf4\uac00 \uc815\ud655\ud788 \uc124\uc815\ub418\uc5b4 \uc788\uc5b4\uc57c \ud569\ub2c8\ub2e4!\n# Path to the wp-config.php file to be newly copied\n# This file must have the correct DB information set for the target server!\nLOCAL_WP_CONFIG_PATH=\"<strong>\/home\/ubuntu\/WordpressConfig\/wp-config.php<\/strong>\"\n\n# --- \ub3c4\uba54\uc778 \uc124\uc815 \/ domain settings ---\n# \uc774\uc804 \ub3c4\uba54\uc778 (\uc6d0\ub798 \uc0ac\uc774\ud2b8 \ub3c4\uba54\uc778)\n# Previous domain (original site domain)\nOLD_DOMAIN=\"<strong>https:\/\/www.yourdoman.com<\/strong>\" \n\n# \uc0c8\ub85c\uc6b4 \ub3c4\uba54\uc778 (\ubcc0\uacbd\ub420 \ub3c4\uba54\uc778)\n# New domain (domain to be changed)\nNEW_DOMAIN=\"<strong>https:\/\/www2.yourdomain.com<\/strong>\" <\/code><\/pre>\n\n\n\n<p><strong>2.wp-config.php<\/strong><\/p>\n\n\n\n<p>&#8212; wp-config.php \ud30c\uc77c\uc744 \uc5f4\uace0  \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc815\ubcf4\ub97c \uc218\uc815\ud569\ub2c8\ub2e4.<br>Open the wp-config.php file and edit the database information.<\/p>\n\n\n\n<p>&#8212;  \uc774 \ud30c\uc77c\uc740 \uc6cc\ub4dc\ud504\ub808\uc2a4 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc124\uc815\ud30c\uc77c\ub85c \uc258\uc2a4\ud06c\ub9bd\uc2a4 \uc2e4\ud589\uc2dc \ubcf5\uad6c\ub420 \uc6cc\ub4dc\ud504\ub808\uc2a4\uc5d0 \uc790\ub3d9\ubcf5\uc0ac\ub429\ub2c8\ub2e4.<br>This file is the WordPress database configuration file and will be automatically copied to the WordPress to be restored when the shell script is executed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define( 'DB_NAME', 'your_db_name' );\n\n\/** Database username *\/\ndefine( 'DB_USER', 'your_db_user' );\n\n\/** Database password *\/\ndefine( 'DB_PASSWORD', 'your_db_password' );<\/code><\/pre>\n\n\n\n<p>\ubaa8\ub4e0 \uc124\uc815\uc774 \uc644\ub8cc\ub418\uc5c8\uc73c\uba74 \ud574\ub2f9 \ub514\ub809\ud1a0\ub9ac\ub85c \uc774\ub3d9\ud574\uc11c sudo .\/wp_restore_sample.sh\ub97c \uc2e4\ud589\ud569\ub2c8\ub2e4.<br>Once everything is set up, go to that directory and run sudo .\/wp_restore_sample.sh.<\/p>\n\n\n\n<p>\uc815\uc0c1\uc801\uc73c\ub85c \uc2e4\ud589\ub418\uae30 \uc704\ud574\uc11c\ub294 \ubc18\ub4dc\uc2dc sudo\uba85\ub839\uc5b4\ub85c \uad00\ub9ac\uc790 \uad8c\ud55c\uc73c\ub85c \uc2e4\ud589\ud574\uc57c \ud569\ub2c8\ub2e4.<br>In order for it to run properly, you must run it with administrator privileges using the sudo command.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uad6c\uae00\ub4dc\ub77c\uc774\ube0c\/Google drive : https:\/\/drive.google.com\/drive\/folders\/1VeFCOlbkxh1ZsUmn6JPfpTSYC_Qj0v9e?usp=drive_link \ubc31\uc5c5\ub41c \uc6cc\ub4dc\ud504\ub808\uc2a4 \uc6f9\ud30c\uc77c\uacfc \ub370\uc774\ud130 \ubca0\uc774\uc2a4 \ud30c\uc77c\uc744 \uc790\ub3d9\ubcf5\uad6c\ud558\ub294 \uc258 \uc2a4\ud06c\ub9bd\ud2b8 \uc785\ub2c8\ub2e4.This is a shell script that automatically restores backed up WordPress web files and database files. \uc218\ub3d9\uc73c\ub85c \uc258\uc2a4\ud06c\ub9bd\ud2b8\ub97c \uc2e4\ud589\ud574\ub3c4 \ub418\uace0 crontab\uc73c\ub85c \uc258\uc2a4\ud06c\ub9bd\ud2b8\ub97c \ud2b9\uc815\uc2dc\uac04\uc5d0 \uc790\ub3d9\uc2e4\ud589 \uc2dc\ud0ac \uc218 \uc788\uc2b5\ub2c8\ub2e4.You can run shell scripts manually or use crontab to automatically run shell scripts at specific [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,1],"tags":[],"class_list":["post-1518","post","type-post","status-publish","format-standard","hentry","category-linux","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/1518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=1518"}],"version-history":[{"count":11,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/1518\/revisions"}],"predecessor-version":[{"id":1530,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/1518\/revisions\/1530"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=1518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=1518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=1518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}