Use rsync to clone one server to another?












4















I have two Debian 9 servers, server A and Server B.



Server A is a LAMP stack server.



Server A is slow. Server B is fast.



I want to clone server A to server B without shutting down server A.



How do I do that?



I think I can do something like this:




  1. Install Debian 9 on server B as a base installation

  2. use rsync to copy over all of /home/ from A to B, then copy over /etc/passwd, /etc/groups, and /etc/shadow

  3. Dump the packages that are installed on A, create a script to install those on B.

  4. Dump the MySQL databases from A, copy to B, and import

  5. Copy over the contents of /etc/ with rsync.


Or... could I just rsync the ENTIRE server from B to A?










share|improve this question





























    4















    I have two Debian 9 servers, server A and Server B.



    Server A is a LAMP stack server.



    Server A is slow. Server B is fast.



    I want to clone server A to server B without shutting down server A.



    How do I do that?



    I think I can do something like this:




    1. Install Debian 9 on server B as a base installation

    2. use rsync to copy over all of /home/ from A to B, then copy over /etc/passwd, /etc/groups, and /etc/shadow

    3. Dump the packages that are installed on A, create a script to install those on B.

    4. Dump the MySQL databases from A, copy to B, and import

    5. Copy over the contents of /etc/ with rsync.


    Or... could I just rsync the ENTIRE server from B to A?










    share|improve this question



























      4












      4








      4








      I have two Debian 9 servers, server A and Server B.



      Server A is a LAMP stack server.



      Server A is slow. Server B is fast.



      I want to clone server A to server B without shutting down server A.



      How do I do that?



      I think I can do something like this:




      1. Install Debian 9 on server B as a base installation

      2. use rsync to copy over all of /home/ from A to B, then copy over /etc/passwd, /etc/groups, and /etc/shadow

      3. Dump the packages that are installed on A, create a script to install those on B.

      4. Dump the MySQL databases from A, copy to B, and import

      5. Copy over the contents of /etc/ with rsync.


      Or... could I just rsync the ENTIRE server from B to A?










      share|improve this question
















      I have two Debian 9 servers, server A and Server B.



      Server A is a LAMP stack server.



      Server A is slow. Server B is fast.



      I want to clone server A to server B without shutting down server A.



      How do I do that?



      I think I can do something like this:




      1. Install Debian 9 on server B as a base installation

      2. use rsync to copy over all of /home/ from A to B, then copy over /etc/passwd, /etc/groups, and /etc/shadow

      3. Dump the packages that are installed on A, create a script to install those on B.

      4. Dump the MySQL databases from A, copy to B, and import

      5. Copy over the contents of /etc/ with rsync.


      Or... could I just rsync the ENTIRE server from B to A?







      debian rsync webserver clone






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 8 at 11:46









      GAD3R

      25.8k1751107




      25.8k1751107










      asked Jan 7 at 17:15









      DrDamnitDrDamnit

      1264




      1264






















          1 Answer
          1






          active

          oldest

          votes


















          3














          Please read over each link carefully before attempting any commands.



          I have used this rsync example by user ericslaw to successfully clone my working Linux install to a different drive.



          You can mount a remote or local target file system to /mnt of your source file system. As root(sudo) run the following:



          mount /dev/sdb1 /mnt


          /dev/sdb1 is your second server disk. It can be remote or local, whatever works best for you.



          rsync -gloptruncv 
          --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
          / /mnt


          This will be a dry run. If there are no errors then you should be good to go to exclude the n option. After which you need to follow the advice in this post. After your back up has completed ( You can even use their options instead depending on your circumstances) Then reset /mnt/etc/fstab for the boot and swap partitions. I highly recommend these entries are based on the UUID of the block devices. blkid will tell the information you need. After fstab is fixed you need to run grub-install /dev/[serverB disk] to be able to boot. Alternatively you can chroot into the backup and install grub that way.



           chroot /mnt
          grub-install --recheck /dev/sdb1
          update-grub


          Lastly you may need to recreate the missing folders of your backup (/dev/, /proc/, /sys/, /tmp/, /run/, /mnt/, /media/, and /lost+found).



          This can also be done in reverse. Have Server B mount Server A's disk and then sync non system files between the two. This is easiest if Server A and B are running the same version of the same distro.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493041%2fuse-rsync-to-clone-one-server-to-another%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            Please read over each link carefully before attempting any commands.



            I have used this rsync example by user ericslaw to successfully clone my working Linux install to a different drive.



            You can mount a remote or local target file system to /mnt of your source file system. As root(sudo) run the following:



            mount /dev/sdb1 /mnt


            /dev/sdb1 is your second server disk. It can be remote or local, whatever works best for you.



            rsync -gloptruncv 
            --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
            / /mnt


            This will be a dry run. If there are no errors then you should be good to go to exclude the n option. After which you need to follow the advice in this post. After your back up has completed ( You can even use their options instead depending on your circumstances) Then reset /mnt/etc/fstab for the boot and swap partitions. I highly recommend these entries are based on the UUID of the block devices. blkid will tell the information you need. After fstab is fixed you need to run grub-install /dev/[serverB disk] to be able to boot. Alternatively you can chroot into the backup and install grub that way.



             chroot /mnt
            grub-install --recheck /dev/sdb1
            update-grub


            Lastly you may need to recreate the missing folders of your backup (/dev/, /proc/, /sys/, /tmp/, /run/, /mnt/, /media/, and /lost+found).



            This can also be done in reverse. Have Server B mount Server A's disk and then sync non system files between the two. This is easiest if Server A and B are running the same version of the same distro.






            share|improve this answer




























              3














              Please read over each link carefully before attempting any commands.



              I have used this rsync example by user ericslaw to successfully clone my working Linux install to a different drive.



              You can mount a remote or local target file system to /mnt of your source file system. As root(sudo) run the following:



              mount /dev/sdb1 /mnt


              /dev/sdb1 is your second server disk. It can be remote or local, whatever works best for you.



              rsync -gloptruncv 
              --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
              / /mnt


              This will be a dry run. If there are no errors then you should be good to go to exclude the n option. After which you need to follow the advice in this post. After your back up has completed ( You can even use their options instead depending on your circumstances) Then reset /mnt/etc/fstab for the boot and swap partitions. I highly recommend these entries are based on the UUID of the block devices. blkid will tell the information you need. After fstab is fixed you need to run grub-install /dev/[serverB disk] to be able to boot. Alternatively you can chroot into the backup and install grub that way.



               chroot /mnt
              grub-install --recheck /dev/sdb1
              update-grub


              Lastly you may need to recreate the missing folders of your backup (/dev/, /proc/, /sys/, /tmp/, /run/, /mnt/, /media/, and /lost+found).



              This can also be done in reverse. Have Server B mount Server A's disk and then sync non system files between the two. This is easiest if Server A and B are running the same version of the same distro.






              share|improve this answer


























                3












                3








                3







                Please read over each link carefully before attempting any commands.



                I have used this rsync example by user ericslaw to successfully clone my working Linux install to a different drive.



                You can mount a remote or local target file system to /mnt of your source file system. As root(sudo) run the following:



                mount /dev/sdb1 /mnt


                /dev/sdb1 is your second server disk. It can be remote or local, whatever works best for you.



                rsync -gloptruncv 
                --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
                / /mnt


                This will be a dry run. If there are no errors then you should be good to go to exclude the n option. After which you need to follow the advice in this post. After your back up has completed ( You can even use their options instead depending on your circumstances) Then reset /mnt/etc/fstab for the boot and swap partitions. I highly recommend these entries are based on the UUID of the block devices. blkid will tell the information you need. After fstab is fixed you need to run grub-install /dev/[serverB disk] to be able to boot. Alternatively you can chroot into the backup and install grub that way.



                 chroot /mnt
                grub-install --recheck /dev/sdb1
                update-grub


                Lastly you may need to recreate the missing folders of your backup (/dev/, /proc/, /sys/, /tmp/, /run/, /mnt/, /media/, and /lost+found).



                This can also be done in reverse. Have Server B mount Server A's disk and then sync non system files between the two. This is easiest if Server A and B are running the same version of the same distro.






                share|improve this answer













                Please read over each link carefully before attempting any commands.



                I have used this rsync example by user ericslaw to successfully clone my working Linux install to a different drive.



                You can mount a remote or local target file system to /mnt of your source file system. As root(sudo) run the following:



                mount /dev/sdb1 /mnt


                /dev/sdb1 is your second server disk. It can be remote or local, whatever works best for you.



                rsync -gloptruncv 
                --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
                / /mnt


                This will be a dry run. If there are no errors then you should be good to go to exclude the n option. After which you need to follow the advice in this post. After your back up has completed ( You can even use their options instead depending on your circumstances) Then reset /mnt/etc/fstab for the boot and swap partitions. I highly recommend these entries are based on the UUID of the block devices. blkid will tell the information you need. After fstab is fixed you need to run grub-install /dev/[serverB disk] to be able to boot. Alternatively you can chroot into the backup and install grub that way.



                 chroot /mnt
                grub-install --recheck /dev/sdb1
                update-grub


                Lastly you may need to recreate the missing folders of your backup (/dev/, /proc/, /sys/, /tmp/, /run/, /mnt/, /media/, and /lost+found).



                This can also be done in reverse. Have Server B mount Server A's disk and then sync non system files between the two. This is easiest if Server A and B are running the same version of the same distro.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 7 at 21:07









                kemotepkemotep

                2,1013620




                2,1013620






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493041%2fuse-rsync-to-clone-one-server-to-another%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Morgemoulin

                    Scott Moir

                    Souastre