{"id":4061,"date":"2016-05-04T15:43:18","date_gmt":"2016-05-04T15:43:18","guid":{"rendered":"http:\/\/www.deuzebranaweb.com.br\/?p=4061"},"modified":"2016-05-04T15:43:18","modified_gmt":"2016-05-04T15:43:18","slug":"copiando-dados-com-o-robocopy","status":"publish","type":"post","link":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/2016\/05\/04\/copiando-dados-com-o-robocopy\/","title":{"rendered":"Copiando dados com o Robocopy"},"content":{"rendered":"<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">Vamos conhecer o utilit\u00e1rio Robust File Copy, mais conhecido como Robocopy que \u00e9 uma ferramenta de linha de comando que realiza c\u00f3pia de dados de uma forma segura e eficiente.<\/span><\/strong><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Aqueles que trabalham com administra\u00e7\u00e3o de redes e servidores de vez em quando realizam a migra\u00e7\u00e3o de dados entre servidores, seja na ocasi\u00e3o de uma m\u00e1quina nova ou mesmo na emerg\u00eancia devido a fato do servidor antigo estar com problemas. Independente da situa\u00e7\u00e3o a transfer\u00eancia de dados entre os servidores sempre ser\u00e1 necess\u00e1ria e esta tarefa se torna um tanto penosa quando n\u00e3o se tem uma ferramenta adequada. Muitos ainda utilizam a c\u00f3pia manual dos dados, que al\u00e9m de ser mais lenta, n\u00e3o retorna nenhum log de verifica\u00e7\u00e3o da c\u00f3pia realizada.<\/span><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Podem ser utilizados softwares e utilit\u00e1rios de backup, sendo que neste caso primeiro \u00e9 feito o backup em alguma m\u00eddia (fita, CD, DVD&#8230;) dos dados do servidor antigo e depois os mesmos s\u00e3o restaurados no servidor novo. Trata-se de uma op\u00e7\u00e3o mais demorada.<\/span><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Temos uma boa op\u00e7\u00e3o chamada Robocopy, que abordaremos neste artigo, que realiza a c\u00f3pia de diret\u00f3rios e arquivos de uma maneira r\u00e1pida, simples e funcional, transferindo inclusive os atributos e permiss\u00f5es NTFS originais dos dados copiados, podendo gerar logs demonstrativos com todas as informa\u00e7\u00f5es sobre a c\u00f3pia e com uma \u00f3tima performance mesmo quando se trata de uma grande massa de dados.<\/span><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">O Robocopy atualmente na vers\u00e3o XP010 \u00e9 uma ferramenta de linha de comando, gratuita dispon\u00edvel desde o Windows NT e que est\u00e1 inclu\u00edda no pacote de ferramentas Resource Kit do Windows Server 2003, que pode ser baixado em <a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?familyid=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&amp;displaylang=en\">http:\/\/www.microsoft.com\/downloads\/details.aspx?familyid=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&amp;displaylang=en<\/a>. Esta vers\u00e3o pode ser utilizada nas vers\u00f5es 2000, XP, 2003 e Vista do Windows. O arquivo execut\u00e1vel possui apenas 78 KB e no diret\u00f3rio onde est\u00e3o as ferramentas do Resource Kit (caso seja mantido o padr\u00e3o da instala\u00e7\u00e3o, C:\\Arquivos de programas\\Windows Resource Kits\\Tools), encontramos o arquivo robocopy.doc, contendo a descri\u00e7\u00e3o da ferramenta e as diversas op\u00e7\u00f5es de sintaxe que o robocopy possui.<\/span><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Outra forma para verificar a sintaxe do comando Robocopy, seria digitando o comando com a op\u00e7\u00e3o <strong style=\"font-style: inherit; font-weight: inherit;\">\/?<\/strong><\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">Op\u00e7\u00f5es de sintaxe para o comando Robocopy<\/span><\/strong><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Um cen\u00e1rio bem interessante para utiliza\u00e7\u00e3o do Robocopy \u00e9 a migra\u00e7\u00e3o de dados entre dois servidores de arquivos. Sabemos que neste caso al\u00e9m da c\u00f3pia \u00e9 necess\u00e1ria a manuten\u00e7\u00e3o dos atributos e permiss\u00f5es dos dados que ser\u00e3o migrados. Podem ser criados arquivos de lotes com chamadas para o Robocopy e sua sintaxe com o intuito de otimizar a tarefa ou at\u00e9 mesmo programar um agendamento.<\/span><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">A sintaxe do comando \u00e9 a seguinte:<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><em style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">Robocopy origem destino [op\u00e7\u00f5es do comando]<\/span><\/em><\/strong><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">Exemplos de utiliza\u00e7\u00e3o do comando<\/span><\/strong><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Vamos ver alguns exemplos de utiliza\u00e7\u00e3o do Robocopy.<\/span><\/p>\n<ol>\n<li><span style=\"font-style: inherit; font-weight: inherit;\"> C\u00f3pia do diret\u00f3rio Scripts armazenado na unidade C para o diret\u00f3rio Backup na unidade D na mesma m\u00e1quina:<\/span><\/li>\n<\/ol>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><em style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">robocopy.exe c:\\scripts d:\\backup<\/span><\/em><\/strong><\/p>\n<ol start=\"2\">\n<li><span style=\"font-style: inherit; font-weight: inherit;\"> C\u00f3pia do mesmo diret\u00f3rio Scripts e dos sub-diret\u00f3rios (op\u00e7\u00e3o \/e) para o diret\u00f3rio Backup:<\/span><\/li>\n<\/ol>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><em style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">robocopy c:\\scripts d:\\backup \/e<\/span><\/em><\/strong><\/p>\n<ol start=\"3\">\n<li><span style=\"font-style: inherit; font-weight: inherit;\"> C\u00f3pia do dados armazenados no compartilhamento Gerencias no Servidor1 para o Servidor 2:<\/span><\/li>\n<\/ol>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><em style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">robocopy \\\\servidor1\\Gerencias\\ \\\\servidor2\\Gerencias\\ \/E \/ZB \/COPYALL \/R:0 \/W:0 \/V \/NP \/ETA \/LOG:c:\\teste-robocopy.log<\/span><\/em><\/strong><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Vejam as op\u00e7\u00f5es do comando utilizadas:<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/E<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> \u2013 C\u00f3pia dos sub-diret\u00f3rios<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/ZB<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> \u2013 Modo Backup<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/COPYALL<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> \u2013 C\u00f3pia de todas as informa\u00e7\u00f5es do arquivo<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/R:0<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> &#8211; n\u00e3o repete a c\u00f3pia em caso de falha<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/W:0<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> &#8211; por n\u00e3o repetir a c\u00f3pia em caso de falha tamb\u00e9m n\u00e3o h\u00e1 tempo de espera entre as repeti\u00e7\u00f5es<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/V<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> &#8211; Exibe os arquivos que por alguma raz\u00e3o n\u00e3o foram copiados<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/NP<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> &#8211; N\u00e3o exibe o progresso da c\u00f3pia<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/ETA<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> &#8211; Exibe o tempo estimado que a c\u00f3pia dos dados levar\u00e1<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">\/LOG:<\/span><\/strong><span style=\"font-style: inherit; font-weight: inherit;\"> &#8211; Especifica o local onde o log ser\u00e1 armazenado<\/span><\/p>\n<p><strong style=\"font-style: inherit; font-weight: inherit;\"><span style=\"font-style: inherit; font-weight: inherit;\">Concluindo<\/span><\/strong><\/p>\n<p><span style=\"font-style: inherit; font-weight: inherit;\">Abordamos neste artigo os conceitos para utiliza\u00e7\u00e3o do comando Robocopy que n\u00e3o deve faltar entre as ferramentas utilizadas por administradores e analista de redes Windows. Vale citar que o utilit\u00e1rio permite uma s\u00e9rie de op\u00e7\u00f5es que n\u00e3o foram abordadas aqui, al\u00e9m de outros cen\u00e1rios e modos de utiliza\u00e7\u00e3o, mas para um aprofundamento vale a pena a leitura do arquivo doc que acompanha o Robocopy.<\/span><\/p>\n<p>Read more: <a style=\"font-style: inherit; font-weight: inherit;\" href=\"http:\/\/www.linhadecodigo.com.br\/artigo\/1342\/copiando-dados-com-o-robocopy.aspx#ixzz47hbQdRy0\">http:\/\/www.linhadecodigo.com.br\/artigo\/1342\/copiando-dados-com-o-robocopy.aspx#ixzz47hbQdRy0<\/a><\/p>\n<p>http:\/\/www.linhadecodigo.com.br\/artigo\/1342\/copiando-dados-com-o-robocopy.aspx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vamos conhecer o utilit\u00e1rio Robust File Copy, mais conhecido como Robocopy que \u00e9 uma ferramenta de linha de comando que realiza c\u00f3pia de dados de uma forma segura e eficiente. Aqueles que trabalham com administra\u00e7\u00e3o de redes e servidores de vez em quando realizam a&#8230;<\/p>\n","protected":false},"author":2,"featured_media":4063,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_angie_page":false,"page_builder":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-4061","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-comandos-linux"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts\/4061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=4061"}],"version-history":[{"count":0,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts\/4061\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/media\/4063"}],"wp:attachment":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=4061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=4061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=4061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}