{"id":2192,"date":"2019-09-23T20:46:06","date_gmt":"2019-09-23T13:46:06","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=2192"},"modified":"2019-09-23T20:46:06","modified_gmt":"2019-09-23T13:46:06","slug":"sao-luu-toan-bo-du-lieu-voi-command-line-tren-direct-admin","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/sao-luu-toan-bo-du-lieu-voi-command-line-tren-direct-admin\/","title":{"rendered":"Sao l\u01b0u to\u00e0n b\u1ed9 d\u1eef li\u1ec7u v\u1edbi Command line tr\u00ean Direct Admin"},"content":{"rendered":"<p>B\u00e0i vi\u1ebft n\u00e0y m\u00ecnh s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n c\u00f3 th\u1ec3 Backup Full Data b\u1eb1ng Command trong qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng n\u1ebfu b\u1ea1n kh\u00f4ng mu\u1ed1n thao t\u00e1c qua giao di\u1ec7n ho\u1eb7c l\u00ed do n\u00e0o \u0111\u00f3.<\/p>\n<h2 id=\"B\u01b0\u1edbc_1_:_Th\u1ef1c_hi\u1ec7n_l\u1ec7nh\">B\u01b0\u1edbc 1 : Th\u1ef1c hi\u1ec7n l\u1ec7nh<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">echo \u201caction=backup&amp;append%5Fto%5Fpath=nothing&amp;database%5Fdata%5Faware=yes&amp;e\r\nmail%5Fdata%5Faware=yes&amp;local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackup\r\ns&amp;owner=admin&amp;type=admin&amp;value=multiple&amp;when=now&amp;where=local&amp;who=all\u201d &gt;&gt;\r\n\/usr\/local\/directadmin\/data\/task.queue<\/pre>\n<p>Thao t\u00e1c n\u00e0y b\u1ea1n s\u1ebd \u0111\u01b0a c\u00f4ng vi\u1ec7c backup c\u1ee7a b\u1ea1n v\u00e0o h\u00e0ng \u0111\u1ee3i \u0111\u1ec3 Backup.<\/p>\n<h2 id=\"B\u01b0\u1edbc_2_:_Th\u1ef1c_hi\u1ec7n_l\u1ec7nh_l\u1ea7n_n\u1eefa\">B\u01b0\u1edbc 2 : Th\u1ef1c hi\u1ec7n l\u1ec7nh l\u1ea7n n\u1eefa<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/usr\/local\/directadmin\/dataskq d200<\/pre>\n<p>L\u1ec7nh n\u00e0y s\u1ebd t\u1ea1o t\u1ea1o ta to\u00e0n b\u1ed9 backup cho t\u1ea5t c\u1ea3 user \u0111\u01b0\u1ee3c l\u01b0u v\u00e0o th\u01b0 m\u1ee5c <strong>\/home\/admin\/admin_backup<\/strong><\/p>\n<p>Tr\u01b0\u1eddng h\u1ee3p m\u00e0 b\u1ea1n mu\u1ed1n thao t\u00e1c Backup cho 1 user m\u00e0 b\u1ea1n mu\u1ed1n ch\u1ec9 \u0111\u1ecbnh c\u00f3 th\u1ec3 l\u00e0m nh\u01b0 sau :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">echo \u201caction=backup&amp;append%5Fto%5Fpath=nothing&amp;database%5Fdata%5Faware=yes&amp;email%5Fdata%5Faware=yes&amp;l\r\nocal%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&amp;owner=admin&amp;select%30=myuser&amp;type=admin&amp;value=multi\r\nple&amp;when=now&amp;where=local\u201d &gt;&gt; \/usr\/local\/directadmin\/data\/task.queue<\/pre>\n<p>V\u1edbi &#8220;<strong>myuser<\/strong>&#8221; b\u1ea1n c\u00f3 th\u1ec3 thay \u0111\u1ed5i th\u00e0nh t\u00e0i kho\u1ea3n c\u1ea7n th\u1ef1c hi\u1ec7n Backup.<\/p>\n<p>Tr\u01b0\u1eddng h\u1ee3p b\u1ea1n mu\u1ed1n kh\u00f4i ph\u1ee5c d\u1eef li\u1ec7u v\u1edbi c\u00e1c b\u1ea3n sao l\u01b0u \u0111\u00e3 t\u1ea1o :<\/p>\n<p>th\u1ef1c hi\u1ec7n l\u1ec7nh sau<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">echo \"action=restore&amp;ip%5Fchoice=file&amp;local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&amp;owner=admin&amp;select%30=user%2Eadmin%2Etestuser%2Etar%2Egz&amp;type=admin&amp;value=multiple&amp;when=now&amp;where=local\" &gt;&gt; \/usr\/local\/directadmin\/data\/task.queue<\/pre>\n<p>V\u1edbi m\u00e3 tr\u00ean th\u00ec <b>user%2Eadmin%2Etestuser%2Etar%2Egz\u00a0<\/b>l\u00e0 t\u00ean c\u1ee7a File m\u00e0 b\u1ea1n c\u1ea7n Restore<\/p>\n<p>d\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t t\u1eadp l\u1ec7nh cron m\u1eabu cho b\u1ea1n, h\u00e3y ch\u1ea1y d\u01b0\u1edbi quy\u1ec1n root, ch\u1ea1y h\u00e0ng ng\u00e0y v\u1edbi c\u00e1ch th\u1ee9c sao l\u01b0u \/ kh\u00f4i ph\u1ee5c, c\u00f3 th\u1ec3 theo t\u00f9y ch\u1ecdn c\u1ee7a b\u1ea1n l\u00e0:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#!\/bin\/sh\r\n\r\n#Who is doing the restore?\r\nOWNER=admin\r\nLOCAL_PATH=\/home\/${OWNER}\/admin_backups\r\n\r\n#choice can be 'file' to get it from the backup\r\n#or 'select' which will use the ip set.\r\nIP_CHOICE=select\r\nIP=1.2.3.4\r\n\r\necho -n \"action=restore&amp;local_path=${LOCAL_PATH}&amp;owner=${OWNER}&amp;when=now&amp;where=local&amp;type=admin\";\r\n\r\nif [ \"${IP_CHOICE}\" = \"select\" ]; then\r\n       echo -n \"&amp;ip_choice=select&amp;ip=${IP}\";\r\nelse\r\n       echo -n \"&amp;ip_choice=${IP_CHOICE}\";\r\nfi\r\n\r\ncd ${LOCAL_PATH}\r\nCOUNT=0\r\nfor i in `\/bin\/ls *.gz`; do\r\n{\r\n       echo -n \"&amp;select${COUNT}=$i\";\r\n       COUNT=$(( $COUNT + 1 ))\r\n};\r\ndone;\r\n\r\necho \"\";\r\n\r\nif [ \"${COUNT}\" -eq 0 ]; then\r\n       exit 1;\r\nfi\r\n\r\nexit 0;<\/pre>\n<p>\u0110\u1ec3 ch\u1ea1y \u0111\u01b0\u1ee3c task n\u00e0y b\u1ea1n s\u1ebd c\u1ea7n t\u1edbi Cron c\u1ee7a m\u00ecnh \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh theo nhu c\u1ea7u c\u1ee7a b\u1ea1n.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/root\/restore_all.sh &gt;&gt; \/usr\/local\/directadmin\/data\/task.queue<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>B\u00e0i vi\u1ebft n\u00e0y m\u00ecnh s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n c\u00f3 th\u1ec3 Backup Full Data b\u1eb1ng Command trong qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng n\u1ebfu b\u1ea1n kh\u00f4ng mu\u1ed1n thao t\u00e1c qua giao di\u1ec7n ho\u1eb7c l\u00ed do n\u00e0o \u0111\u00f3. B\u01b0\u1edbc 1 : Th\u1ef1c hi\u1ec7n l\u1ec7nh echo \u201caction=backup&amp;append%5Fto%5Fpath=nothing&amp;database%5Fdata%5Faware=yes&amp;e mail%5Fdata%5Faware=yes&amp;local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackup s&amp;owner=admin&amp;type=admin&amp;value=multiple&amp;when=now&amp;where=local&amp;who=all\u201d &gt;&gt; \/usr\/local\/directadmin\/data\/task.queue Thao t\u00e1c n\u00e0y b\u1ea1n s\u1ebd \u0111\u01b0a c\u00f4ng vi\u1ec7c backup [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[23],"class_list":["post-2192","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-control-panel-direct-admin"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=2192"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/2192\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=2192"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=2192"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=2192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}