{"id":383,"date":"2017-01-28T23:24:36","date_gmt":"2017-01-28T14:24:36","guid":{"rendered":"https:\/\/blog.chanha.me\/?p=383"},"modified":"2017-01-29T01:06:43","modified_gmt":"2017-01-28T16:06:43","slug":"crontab%ec%9d%84-%ed%86%b5%ed%95%9c-%eb%b0%b1%ec%97%85rsync-%eb%94%94%ec%8a%a4%ed%81%ac%ea%b2%80%ec%82%ac%ed%95%98%ea%b8%b0-%eb%b0%8f-%ec%9d%b4%eb%a9%94%ec%9d%bc-%ec%95%8c%eb%a6%bc","status":"publish","type":"post","link":"https:\/\/blog.chanha.kr\/?p=383","title":{"rendered":"Crontab\uc744 \ud1b5\ud55c \ubc31\uc5c5(Rsync), \ub514\uc2a4\ud06c\uac80\uc0ac\ud558\uae30 \ubc0f \uc774\uba54\uc77c \uc54c\ub9bc"},"content":{"rendered":"<p>Nextcloud\ub97c \uc774\uc6a9\ud55c \ub3d9\uae30\ud654\ub97c \uc0ac\uc6a9\ud55c\ub2e4\uace0 \ud558\ub354\ub77c\ub3c4<\/p>\n<p>\ubcc4\uac1c\ub85c \uc77c\uc8fc\uc77c\uc774\ub098 \ud55c\ub2ec\ub9c8\ub2e4 \ub370\uc774\ud130 \uc190\uc2e4\uc744 \ubc29\uc9c0\ud558\uae30 \uc704\ud574 \ubc31\uc5c5\uc744 \uc124\uc815\ud558\ub294 \uac83\uc774 \uc88b\ub2e4.<\/p>\n<p>\ubc31\uc5c5\uc744 \uc190\uc27d\uace0 \ube60\ub974\uac8c \ud558\uae30 \uc704\ud574\uc11c rsync\ub77c\ub294 \ud328\ud0a4\uc9c0\ub97c \uc774\uc6a9\ud574\uc11c \uac04\ub2e8\ud55c \ubc31\uc5c5\uc744 \uad6c\uc131\ud558\uace0<\/p>\n<p>\uc774\ub97c crontab\uc744 \uc774\uc6a9\ud574\uc11c \uc8fc\uae30\uc801\uc73c\ub85c \uc2e4\ud589\ud558\uace0, \uc774\uba54\uc77c\uc54c\ub9bc\uc744 \ubc1b\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\ubcf4\uc790.<\/p>\n<p>\uc6b0\uc120 rsync\uc744 \uc124\uce58\ud55c\ub2e4.<\/p>\n<pre class=\"lang:sh decode:true \">sudo apt-get install -y rsync<\/pre>\n<p>\uadf8 \ud6c4 \uc784\uc758\uc758 \uc704\uce58\uc5d0<\/p>\n<pre class=\"lang:default decode:true\">sudo vim &lt;\uc2a4\ud06c\ub9bd\ud2b8\uc774\ub984&gt;.sh<\/pre>\n<p>\ub97c \ud1b5\ud574 \uc2a4\ud06c\ub9bd\ud2b8\ud30c\uc77c\uc744 \uc0dd\uc131\ud55c\ub4a4,<\/p>\n<pre class=\"lang:sh decode:true\">#!\/bin\/bash\r\n\r\n# Script to backup personal files to the external USB drive.\r\n# Specify the mount point here (DO NOT end mount_point with a forward-slash).\r\nmount_point=&lt;\ubc31\uc5c5\uc744 \uc800\uc7a5\ud560 \ub9c8\uc6b4\ud2b8\uc704\uce58&gt;\r\n\r\necho \"#####\"\r\necho \"\"\r\n# Check whether target volume is mounted, and mount it if not.\r\nif ! mountpoint -q ${mount_point}\/; then\r\n     echo \"Mounting the external USB drive.\"\r\n     echo \"Mountpoint is ${mount_point}\"\r\n     if ! mount ${mount_point}; then\r\n        echo \"An error code was returned by mount command!\"\r\n        exit 5\r\n     else echo \"Mounted successfully.\";\r\n     fi\r\nelse echo \"${mount_point} is already mounted.\";\r\nfi\r\n# Target volume **must** be mounted by this point. If not, die screaming.\r\nif ! mountpoint -q ${mount_point}\/; then\r\n     echo \"Mounting failed! Cannot run backup without backup volume!\"\r\n     exit 1\r\nfi\r\n\r\necho \"Preparing to transfer differences using rsync.\"\r\n\r\n# Use the year to create a new backup directory each year.\r\n# current_year=`date +%Y`\r\n# Now construct the backup path, specifying the mount point followed by the path\r\n# to our backup directory, finishing with the current year.\r\n# (DO NOT end backup_path with a forward-slash.)\r\n# backup_path=${mount_point}'\/rsync-backup\/'${current_year}\r\nbackup_path=${mount_point}'\/rsync-backup'\r\n\r\necho \"Backup storage directory path is ${backup_path}\"\r\n\r\necho \"Starting backup of &lt;\ubc31\uc5c5\ud560 \ub514\ub809\ud1a0\ub9ac&gt; . . . \"\r\nmkdir --parents ${backup_path}\/&lt;\ubc31\uc5c5\uc704\uce58&gt;\r\n# This time use the -a flag with the tee command, so that it appends to the end\r\n# of the rsync-output.txt file rather than start a new file from scratch.\r\nsudo rsync --archive --verbose --human-readable --itemize-changes --progress --no-o --no-g \\\r\n--delete --delete-excluded \\\r\n&lt;\ubc31\uc5c5\ud560 \ub514\ub809\ud1a0\ub9ac&gt;\/ ${backup_path}\/&lt;\ubc31\uc5c5\uc704\uce58&gt;\/ 2&gt;&amp;1 | tee -a \/backup\/log\/&lt;\ubc31\uc5c5\uc704\uce58&gt;.txt\r\n\r\necho \"\"\r\necho \"####\"\r\n\r\ntail \/backup\/log\/&lt;\ubc31\uc5c5\uc704\uce58&gt;.txt |  mail -a \"From: Backup\" -s \"\ubb38\uc11c \ubc31\uc5c5 \uc644\ub8cc\" &lt;\uc774\uba54\uc77c\uc8fc\uc18c&gt;\r\n<\/pre>\n<p>\ub97c \uc218\uc815\ud574 \uc800\uc7a5\ud574\uc900\ub2e4.<\/p>\n<blockquote><p>&lt;\ubc31\uc5c5\uc744 \uc800\uc7a5\ud560 \ub9c8\uc6b4\ud2b8\uc704\uce58&gt;\ub294 USB\ub098 \uc678\uc7a5\ud558\ub4dc\uc758 \ub9c8\uc6b4\ud2b8\uc704\uce58\ub97c \ub9d0\ud55c\ub2e4.<\/p>\n<p>&lt;\ubc31\uc5c5\ud560 \ub514\ub809\ud1a0\ub9ac&gt;\ub294 \ubc31\uc5c5\uc744 \uc2e4\ud589\ud560 \ub514\ud14d\ud1a0\ub9ac\ub97c \uc598\uae30\ud558\uace0<\/p>\n<p>&lt;\ubc31\uc5c5\uc704\uce58&gt;\ub294 \ubc31\uc5c5\uc774 \uc800\uc7a5\ub420 \ub514\ub809\ud1a0\ub9ac\ub97c \uc758\ubbf8\ud55c\ub2e4. (\ub9c8\uc6b4\ud2b8\uc704\uce58\/rsync-backup\/ \uc544\ub798\uc5d0 \uc0dd\uc131\ub418\ub294 \ub514\ub809\ud1a0\ub9ac\ub2e4)<\/p><\/blockquote>\n<p>\uadf8 \ud6c4<\/p>\n<pre class=\"lang:sh decode:true\">sudo chmod +x &lt;\uc2a4\ud06c\ub9bd\ud2b8\uc774\ub984&gt;.sh<\/pre>\n<p>\ub97c \ud1b5\ud574\uc11c \uc2e4\ud589 \uad8c\ud55c\uc744 \ubd80\uc5ec\ud55c \ub4a4,<\/p>\n<pre class=\"lang:sh decode:true \">sudo crontab -e<\/pre>\n<p>\uba85\ub839\uc5b4\ub97c \ud1b5\ud574 crontab \uc5d0\ub514\ud130\ub97c \uc5f4\uc5b4\uc900\ub2e4.<\/p>\n<p>\uadf8 \ud6c4 <a href=\"http:\/\/zetawiki.com\/wiki\/%EB%A6%AC%EB%88%85%EC%8A%A4_%EB%B0%98%EB%B3%B5_%EC%98%88%EC%95%BD%EC%9E%91%EC%97%85_cron,_crond,_crontab\" target=\"_blank\">crontab\uc815\ubcf4<\/a>\ub97c \ucc38\uace0\ud574 \uc8fc\uae30\ub97c \uc124\uc815\ud55c \ub4a4 \ucee4\ub9e8\ub4dc \uc2a4\ud06c\ub9bd\ud2b8\uc758 \ucd1d\uacbd\ub85c\ub97c \ucd94\uac00\ud55c\ub4a4 \uc800\uc7a5\ud574\uc900\ub2e4.<\/p>\n<blockquote><p>ex) 30 5 * * 1 \/usr\/local\/bin\/script\/&lt;\uc2a4\ud06c\ub9bd\ud2b8\uc774\ub984&gt;.sh<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<p>\uadf8 \ud6c4 \uc8fc\uae30\uc801\uc778 \ub514\uc2a4\ud06c \uac80\uc0ac\ub97c \uc704\ud574\uc11c<\/p>\n<pre class=\"lang:sh decode:true\">sudo apt-get install smartmontools<\/pre>\n<p>\uba85\ub839\uc5b4\ub97c \ud1b5\ud574 smartctl\ub97c \uc124\uce58\ud574\uc900\ub2e4.<\/p>\n<p>\uadf8 \ud6c4 crontab \uc5d0\ub514\ud130\ub97c \uc5f4\uc5b4 \uc8fc\uae30\ub97c \uc124\uc815\ud55c \ub4a4,<\/p>\n<pre class=\"lang:sh decode:true \">\/usr\/sbin\/smartctl -H -l selftest -l error \/dev\/sdb | mail -a \"From: DiskCheck\" -s \"\uc8fc\uac04 \ub514\uc2a4\ud06c \uac80\uc0ac \uacb0\uacfc\" &lt;\uc774\uba54\uc77c\uc8fc\uc18c&gt;<\/pre>\n<p>\ub97c \ucd94\uac00\ud574\uc8fc\uba74 \uc77c\uc815\uc8fc\uae30\ub9c8\ub2e4 \ub514\uc2a4\ud06c\uac80\uc0ac\ub97c \ud55c\ub4a4 \uc774\uba54\uc77c\ub85c \uadf8 \ub0b4\uc6a9\uc774 \uc54c\ub9bc\uc774 \uac00\uac8c \ub41c\ub2e4.<\/p>\n<p>&nbsp;<\/p>\n<div class='ez_cc_license_block'><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/4.0\/\"><img decoding=\"async\" alt=\"Creative Commons License\" style=\"border-width:0\" src=\"http:\/\/i.creativecommons.org\/l\/by-nc-sa\/4.0\/88x31.png\"\/><\/a><br\/>This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/4.0\/\">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License<\/a>.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Nextcloud\ub97c \uc774\uc6a9\ud55c \ub3d9\uae30\ud654\ub97c \uc0ac\uc6a9\ud55c\ub2e4\uace0 \ud558\ub354\ub77c\ub3c4 \ubcc4\uac1c\ub85c \uc77c\uc8fc\uc77c\uc774\ub098 \ud55c\ub2ec\ub9c8\ub2e4 \ub370\uc774\ud130 \uc190\uc2e4\uc744 \ubc29\uc9c0\ud558\uae30 \uc704\ud574 \ubc31\uc5c5\uc744 \uc124\uc815\ud558\ub294 \uac83\uc774 \uc88b\ub2e4. \ubc31\uc5c5\uc744 \uc190\uc27d\uace0 \ube60\ub974\uac8c \ud558\uae30 \uc704\ud574\uc11c rsync\ub77c\ub294 \ud328\ud0a4\uc9c0\ub97c \uc774\uc6a9\ud574\uc11c \uac04\ub2e8\ud55c \ubc31\uc5c5\uc744 \uad6c\uc131\ud558\uace0 \uc774\ub97c crontab\uc744 \uc774\uc6a9\ud574\uc11c \uc8fc\uae30\uc801\uc73c\ub85c \uc2e4\ud589\ud558\uace0, \uc774\uba54\uc77c\uc54c\ub9bc\uc744 \ubc1b\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\ubcf4\uc790. \uc6b0\uc120 rsync\uc744 \uc124\uce58\ud55c\ub2e4. sudo apt-get install -y rsync \uadf8 \ud6c4 \uc784\uc758\uc758 \uc704\uce58\uc5d0 sudo vim &lt;\uc2a4\ud06c\ub9bd\ud2b8\uc774\ub984&gt;.sh \ub97c \ud1b5\ud574 \uc2a4\ud06c\ub9bd\ud2b8\ud30c\uc77c\uc744 \uc0dd\uc131\ud55c\ub4a4, #!\/bin\/bash # Script to backup [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-nas","clearfix"],"_links":{"self":[{"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383"}],"version-history":[{"count":3,"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions"}],"predecessor-version":[{"id":388,"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=\/wp\/v2\/posts\/383\/revisions\/388"}],"wp:attachment":[{"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.chanha.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}