Which Folders To Include In backup?












27















I'm quite new to Ubuntu and want to create a backup. I'm really not sure what files and folders to include so that if I restore my system it will be as it is now. I can't seem to find good details of this anywhere. Hopefully someone could help me with this. Is it possible to backup everything as it is now so in the event of a system restore I don't have to reinstall programs and settings?










share|improve this question

























  • Yeah I too want to know what the important files are without having to backup the entire drive. Crontabs (root and user), exportfs etc.

    – Sridhar-Sarnobat
    Jun 3 '18 at 18:06
















27















I'm quite new to Ubuntu and want to create a backup. I'm really not sure what files and folders to include so that if I restore my system it will be as it is now. I can't seem to find good details of this anywhere. Hopefully someone could help me with this. Is it possible to backup everything as it is now so in the event of a system restore I don't have to reinstall programs and settings?










share|improve this question

























  • Yeah I too want to know what the important files are without having to backup the entire drive. Crontabs (root and user), exportfs etc.

    – Sridhar-Sarnobat
    Jun 3 '18 at 18:06














27












27








27


13






I'm quite new to Ubuntu and want to create a backup. I'm really not sure what files and folders to include so that if I restore my system it will be as it is now. I can't seem to find good details of this anywhere. Hopefully someone could help me with this. Is it possible to backup everything as it is now so in the event of a system restore I don't have to reinstall programs and settings?










share|improve this question
















I'm quite new to Ubuntu and want to create a backup. I'm really not sure what files and folders to include so that if I restore my system it will be as it is now. I can't seem to find good details of this anywhere. Hopefully someone could help me with this. Is it possible to backup everything as it is now so in the event of a system restore I don't have to reinstall programs and settings?







backup directory






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 19 '18 at 17:50









7ochem

174212




174212










asked Nov 26 '12 at 22:52









JasonJason

136123




136123













  • Yeah I too want to know what the important files are without having to backup the entire drive. Crontabs (root and user), exportfs etc.

    – Sridhar-Sarnobat
    Jun 3 '18 at 18:06



















  • Yeah I too want to know what the important files are without having to backup the entire drive. Crontabs (root and user), exportfs etc.

    – Sridhar-Sarnobat
    Jun 3 '18 at 18:06

















Yeah I too want to know what the important files are without having to backup the entire drive. Crontabs (root and user), exportfs etc.

– Sridhar-Sarnobat
Jun 3 '18 at 18:06





Yeah I too want to know what the important files are without having to backup the entire drive. Crontabs (root and user), exportfs etc.

– Sridhar-Sarnobat
Jun 3 '18 at 18:06










7 Answers
7






active

oldest

votes


















21














My backup sets currently contain



/var (except /var/run, /var/cache, /var/tmp)
/srv
/etc
/root
/home
/usr (/usr/local only, nothing else)


Note this is for a server, so backing up things like /etc saves all my configuration for my services, I have web servers in /srv (though if you have them in /var/www, they would still be in this backup set), I have various scripts and things set up in /usr/local, etc. Backing up /home instead of /home/myusername is so that I can preserve all users. If all you want to keep is your user data, you only need your home directory.






share|improve this answer
























  • Why are you including /root?

    – Mohammed Joraid
    Jul 19 '17 at 10:03








  • 2





    It's the home directory of the root user, I keep some sysadmin scripts in there, for backup etc. Though I've moved most of these to /usr/local/sbin/

    – thomasrutter
    Jul 21 '17 at 11:03





















9














What you need to backup depends on your particular system*.



So this is going to take a little work on your part to sort out. Start by figuring out what does not need to be backed up. First take a look at your root directory, and then work backwards.



For example, cd /; ls -F gives me:



bin/    initrd.img@      mnt/   snap/  vmlinuz@
boot/ initrd.img.old@ opt/ srv/ vmlinuz.old@
cdrom/ lib/ proc/ sys/
dev/ lib64/ root/ tmp/
etc/ lost+found/ run/ usr/
home/ media/ sbin/ var/


/cdrom, /media, and /mnt are mount points so don't need backup.



/dev, /lost+found, /proc, /run, /sys and /tmp get auto re-created on reboot. [I'm guessing the links: /initrd.img@, /initrd.img.old@, /vmlinuz@, /vmlinuz.old@ get re-created on boot ubuntu reinstall (I'm not sure which).]



On my system /root is empty (use sudo -s to open a shell as root user to view it ... be careful to exit immediately after you inspect /root.)



/snap is also empty. Perhaps it's a mount point.



/var contains variable data like system logging files, mail and printer spool directories, and transient and temporary files." I now back it up, except for /var/log. ref: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/var.html)



/bin, /boot, /lib, /lib64, and /sbin presumably will get reloaded via a reinstall of Ubuntu unless you are doing system development work or something like that. You can either back these up or rely on a fresh install to recover them.



/home should be in it's own backup. There will be times when you will want to restore just /home.



That leaves other changes you've made to your system in /etc, /opt, /srv, and /usr which you will want to also backup, either together or individually.



Here are a couple of pages that might help understand these directories:



http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/the-root-directory.html
http://www.tldp.org/LDP/intro-linux/html/sect_03_01.html#sect_03_01_03





A related line of thinking is: Say you just installed a fresh Ubuntu. What would you need to back up? Answer: nothing. You haven't changed anything yet, so you can simply reinstall Ubuntu. It restores /bin, /etc, /root, /usr, etc.



So the only reason you might want to backup /bin is because you have changed it or added to it. So part of backing up is understanding what is where and when it is created and modified. Just know that the rest of us struggle with this too.





*****And, although you didn't ask, one can make full disk or partition images. These take a lot of time to backup and restore and may leave your system down while that work is proceeding. And it's how I used to backup my Windows systems using Acronis. The one thing they provide you with is a partition map, and images from non-linux partitions. I now make these before I reorganize partitions, and before I test my backup restore functions.





(I'm very open to suggestions as to how I could make this better.)






share|improve this answer


























  • This is great when you're focussed on configurations and don't need the binaries, like you said they can be installed again and this is much lighter to export and than to reinstall askubuntu.com/a/55906/104223

    – CTS_AE
    Jan 17 '17 at 4:39





















5














If I reinstall my desktop system, I backup




  • /etc


  • /var, I'm too lazy to exclude some sub-folders

  • /opt


/home is on a separate partition and has a backup made every day.



After the reinstall, I restore the parts from my backup, which I really need.



With this strategy, all my configurations, local mails and crontab configurations are safe and I have to reinstall my needed applications only.



My personal scripts are saved in my home folder (daily backup, remember?), therefore I don't use /usr/local.








share|improve this answer





















  • 1





    Will it work if I backup root, that is everything?: ./

    – Suspended
    Feb 25 '16 at 13:25











  • That would be like a clone of what I'm using now.

    – Suspended
    Feb 25 '16 at 13:26



















3














Most people just backup their home directory: /home/$USER/. If you want to back up the configuration files and settings, those are stored in folders and files in your home directory that start with a . (dot). Make a list of packages that you use (and PPAs) and it will be easy to reinstall all your packages should you need. Or, use the command described in this comment.



Deja Dup Backup is a great tool that comes as a default on Ubuntu. Other options include command line (rsync, rsnapshot, rdiff-backup, etc).



Finally, to backup the whole disk as an image, check out clonezilla.






share|improve this answer





















  • 2





    Also, in addition to what the answer psny linked to, it wouldn't hurt to create a back up of the whole /etc/ directory which stores system wide settings. If you've made some changes there, it would be helpful to have an archive to get those changes from.

    – Marcin Kaminski
    Dec 1 '12 at 15:12






  • 2





    If you have any crontabs setup, then backup /var/spool/cron too.

    – Ian Dunn
    Apr 29 '15 at 7:08



















2














Let's collect a list of files here. I've made this post "community wiki."



Of course, it varies from person to person. Mine is used mainly as a web server and NFS server.



mkdir $MY_BACKUP_FOLDER
cd $MY_BACKUP_FOLDER


crontabs



sudo rsync -a --relative /var/spool/cron/crontabs .


NFS shares



sudo rsync -a --relative /etc/exports .


sudoers



sudo rsync -a --relative /etc/sudoers .


apache config



sudo rsync -a --relative /etc/apache2/apache2.conf .


autofs



sudo rsync -a --relative /etc/auto* .


fstab



sudo rsync -a --relative /etc/fstab .


hosts



sudo rsync -a --relative /etc/hosts .


samba



sudo rsync -a --relative /etc/samba/smb.conf .


systemd



mlocate



sudo rsync -a --relative /etc/updatedb.conf .


home dir can be preserved if you do a ubuntu reinstall






share|improve this answer

































    1














    Just a reminder if you're using DejaDup (or anything else really), also exclude any cloud storage folders (likely in your home), such as Dropbox. If you're paying for s3 storage this could be a bad mistake.






    share|improve this answer































      0














      Use Deja Dup backup. It is provided by default. Go to settings and keep only root folder (/) as "folders to include" and add media folder (/media) in "folders to ignore".



      Because of this, all your programs will be backed up in case of system damage (rare) except your other drives which normally remain unaffected.






      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "89"
        };
        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: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        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%2faskubuntu.com%2fquestions%2f222326%2fwhich-folders-to-include-in-backup%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        7 Answers
        7






        active

        oldest

        votes








        7 Answers
        7






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        21














        My backup sets currently contain



        /var (except /var/run, /var/cache, /var/tmp)
        /srv
        /etc
        /root
        /home
        /usr (/usr/local only, nothing else)


        Note this is for a server, so backing up things like /etc saves all my configuration for my services, I have web servers in /srv (though if you have them in /var/www, they would still be in this backup set), I have various scripts and things set up in /usr/local, etc. Backing up /home instead of /home/myusername is so that I can preserve all users. If all you want to keep is your user data, you only need your home directory.






        share|improve this answer
























        • Why are you including /root?

          – Mohammed Joraid
          Jul 19 '17 at 10:03








        • 2





          It's the home directory of the root user, I keep some sysadmin scripts in there, for backup etc. Though I've moved most of these to /usr/local/sbin/

          – thomasrutter
          Jul 21 '17 at 11:03


















        21














        My backup sets currently contain



        /var (except /var/run, /var/cache, /var/tmp)
        /srv
        /etc
        /root
        /home
        /usr (/usr/local only, nothing else)


        Note this is for a server, so backing up things like /etc saves all my configuration for my services, I have web servers in /srv (though if you have them in /var/www, they would still be in this backup set), I have various scripts and things set up in /usr/local, etc. Backing up /home instead of /home/myusername is so that I can preserve all users. If all you want to keep is your user data, you only need your home directory.






        share|improve this answer
























        • Why are you including /root?

          – Mohammed Joraid
          Jul 19 '17 at 10:03








        • 2





          It's the home directory of the root user, I keep some sysadmin scripts in there, for backup etc. Though I've moved most of these to /usr/local/sbin/

          – thomasrutter
          Jul 21 '17 at 11:03
















        21












        21








        21







        My backup sets currently contain



        /var (except /var/run, /var/cache, /var/tmp)
        /srv
        /etc
        /root
        /home
        /usr (/usr/local only, nothing else)


        Note this is for a server, so backing up things like /etc saves all my configuration for my services, I have web servers in /srv (though if you have them in /var/www, they would still be in this backup set), I have various scripts and things set up in /usr/local, etc. Backing up /home instead of /home/myusername is so that I can preserve all users. If all you want to keep is your user data, you only need your home directory.






        share|improve this answer













        My backup sets currently contain



        /var (except /var/run, /var/cache, /var/tmp)
        /srv
        /etc
        /root
        /home
        /usr (/usr/local only, nothing else)


        Note this is for a server, so backing up things like /etc saves all my configuration for my services, I have web servers in /srv (though if you have them in /var/www, they would still be in this backup set), I have various scripts and things set up in /usr/local, etc. Backing up /home instead of /home/myusername is so that I can preserve all users. If all you want to keep is your user data, you only need your home directory.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 15 '15 at 4:21









        thomasrutterthomasrutter

        26.7k46489




        26.7k46489













        • Why are you including /root?

          – Mohammed Joraid
          Jul 19 '17 at 10:03








        • 2





          It's the home directory of the root user, I keep some sysadmin scripts in there, for backup etc. Though I've moved most of these to /usr/local/sbin/

          – thomasrutter
          Jul 21 '17 at 11:03





















        • Why are you including /root?

          – Mohammed Joraid
          Jul 19 '17 at 10:03








        • 2





          It's the home directory of the root user, I keep some sysadmin scripts in there, for backup etc. Though I've moved most of these to /usr/local/sbin/

          – thomasrutter
          Jul 21 '17 at 11:03



















        Why are you including /root?

        – Mohammed Joraid
        Jul 19 '17 at 10:03







        Why are you including /root?

        – Mohammed Joraid
        Jul 19 '17 at 10:03






        2




        2





        It's the home directory of the root user, I keep some sysadmin scripts in there, for backup etc. Though I've moved most of these to /usr/local/sbin/

        – thomasrutter
        Jul 21 '17 at 11:03







        It's the home directory of the root user, I keep some sysadmin scripts in there, for backup etc. Though I've moved most of these to /usr/local/sbin/

        – thomasrutter
        Jul 21 '17 at 11:03















        9














        What you need to backup depends on your particular system*.



        So this is going to take a little work on your part to sort out. Start by figuring out what does not need to be backed up. First take a look at your root directory, and then work backwards.



        For example, cd /; ls -F gives me:



        bin/    initrd.img@      mnt/   snap/  vmlinuz@
        boot/ initrd.img.old@ opt/ srv/ vmlinuz.old@
        cdrom/ lib/ proc/ sys/
        dev/ lib64/ root/ tmp/
        etc/ lost+found/ run/ usr/
        home/ media/ sbin/ var/


        /cdrom, /media, and /mnt are mount points so don't need backup.



        /dev, /lost+found, /proc, /run, /sys and /tmp get auto re-created on reboot. [I'm guessing the links: /initrd.img@, /initrd.img.old@, /vmlinuz@, /vmlinuz.old@ get re-created on boot ubuntu reinstall (I'm not sure which).]



        On my system /root is empty (use sudo -s to open a shell as root user to view it ... be careful to exit immediately after you inspect /root.)



        /snap is also empty. Perhaps it's a mount point.



        /var contains variable data like system logging files, mail and printer spool directories, and transient and temporary files." I now back it up, except for /var/log. ref: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/var.html)



        /bin, /boot, /lib, /lib64, and /sbin presumably will get reloaded via a reinstall of Ubuntu unless you are doing system development work or something like that. You can either back these up or rely on a fresh install to recover them.



        /home should be in it's own backup. There will be times when you will want to restore just /home.



        That leaves other changes you've made to your system in /etc, /opt, /srv, and /usr which you will want to also backup, either together or individually.



        Here are a couple of pages that might help understand these directories:



        http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/the-root-directory.html
        http://www.tldp.org/LDP/intro-linux/html/sect_03_01.html#sect_03_01_03





        A related line of thinking is: Say you just installed a fresh Ubuntu. What would you need to back up? Answer: nothing. You haven't changed anything yet, so you can simply reinstall Ubuntu. It restores /bin, /etc, /root, /usr, etc.



        So the only reason you might want to backup /bin is because you have changed it or added to it. So part of backing up is understanding what is where and when it is created and modified. Just know that the rest of us struggle with this too.





        *****And, although you didn't ask, one can make full disk or partition images. These take a lot of time to backup and restore and may leave your system down while that work is proceeding. And it's how I used to backup my Windows systems using Acronis. The one thing they provide you with is a partition map, and images from non-linux partitions. I now make these before I reorganize partitions, and before I test my backup restore functions.





        (I'm very open to suggestions as to how I could make this better.)






        share|improve this answer


























        • This is great when you're focussed on configurations and don't need the binaries, like you said they can be installed again and this is much lighter to export and than to reinstall askubuntu.com/a/55906/104223

          – CTS_AE
          Jan 17 '17 at 4:39


















        9














        What you need to backup depends on your particular system*.



        So this is going to take a little work on your part to sort out. Start by figuring out what does not need to be backed up. First take a look at your root directory, and then work backwards.



        For example, cd /; ls -F gives me:



        bin/    initrd.img@      mnt/   snap/  vmlinuz@
        boot/ initrd.img.old@ opt/ srv/ vmlinuz.old@
        cdrom/ lib/ proc/ sys/
        dev/ lib64/ root/ tmp/
        etc/ lost+found/ run/ usr/
        home/ media/ sbin/ var/


        /cdrom, /media, and /mnt are mount points so don't need backup.



        /dev, /lost+found, /proc, /run, /sys and /tmp get auto re-created on reboot. [I'm guessing the links: /initrd.img@, /initrd.img.old@, /vmlinuz@, /vmlinuz.old@ get re-created on boot ubuntu reinstall (I'm not sure which).]



        On my system /root is empty (use sudo -s to open a shell as root user to view it ... be careful to exit immediately after you inspect /root.)



        /snap is also empty. Perhaps it's a mount point.



        /var contains variable data like system logging files, mail and printer spool directories, and transient and temporary files." I now back it up, except for /var/log. ref: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/var.html)



        /bin, /boot, /lib, /lib64, and /sbin presumably will get reloaded via a reinstall of Ubuntu unless you are doing system development work or something like that. You can either back these up or rely on a fresh install to recover them.



        /home should be in it's own backup. There will be times when you will want to restore just /home.



        That leaves other changes you've made to your system in /etc, /opt, /srv, and /usr which you will want to also backup, either together or individually.



        Here are a couple of pages that might help understand these directories:



        http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/the-root-directory.html
        http://www.tldp.org/LDP/intro-linux/html/sect_03_01.html#sect_03_01_03





        A related line of thinking is: Say you just installed a fresh Ubuntu. What would you need to back up? Answer: nothing. You haven't changed anything yet, so you can simply reinstall Ubuntu. It restores /bin, /etc, /root, /usr, etc.



        So the only reason you might want to backup /bin is because you have changed it or added to it. So part of backing up is understanding what is where and when it is created and modified. Just know that the rest of us struggle with this too.





        *****And, although you didn't ask, one can make full disk or partition images. These take a lot of time to backup and restore and may leave your system down while that work is proceeding. And it's how I used to backup my Windows systems using Acronis. The one thing they provide you with is a partition map, and images from non-linux partitions. I now make these before I reorganize partitions, and before I test my backup restore functions.





        (I'm very open to suggestions as to how I could make this better.)






        share|improve this answer


























        • This is great when you're focussed on configurations and don't need the binaries, like you said they can be installed again and this is much lighter to export and than to reinstall askubuntu.com/a/55906/104223

          – CTS_AE
          Jan 17 '17 at 4:39
















        9












        9








        9







        What you need to backup depends on your particular system*.



        So this is going to take a little work on your part to sort out. Start by figuring out what does not need to be backed up. First take a look at your root directory, and then work backwards.



        For example, cd /; ls -F gives me:



        bin/    initrd.img@      mnt/   snap/  vmlinuz@
        boot/ initrd.img.old@ opt/ srv/ vmlinuz.old@
        cdrom/ lib/ proc/ sys/
        dev/ lib64/ root/ tmp/
        etc/ lost+found/ run/ usr/
        home/ media/ sbin/ var/


        /cdrom, /media, and /mnt are mount points so don't need backup.



        /dev, /lost+found, /proc, /run, /sys and /tmp get auto re-created on reboot. [I'm guessing the links: /initrd.img@, /initrd.img.old@, /vmlinuz@, /vmlinuz.old@ get re-created on boot ubuntu reinstall (I'm not sure which).]



        On my system /root is empty (use sudo -s to open a shell as root user to view it ... be careful to exit immediately after you inspect /root.)



        /snap is also empty. Perhaps it's a mount point.



        /var contains variable data like system logging files, mail and printer spool directories, and transient and temporary files." I now back it up, except for /var/log. ref: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/var.html)



        /bin, /boot, /lib, /lib64, and /sbin presumably will get reloaded via a reinstall of Ubuntu unless you are doing system development work or something like that. You can either back these up or rely on a fresh install to recover them.



        /home should be in it's own backup. There will be times when you will want to restore just /home.



        That leaves other changes you've made to your system in /etc, /opt, /srv, and /usr which you will want to also backup, either together or individually.



        Here are a couple of pages that might help understand these directories:



        http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/the-root-directory.html
        http://www.tldp.org/LDP/intro-linux/html/sect_03_01.html#sect_03_01_03





        A related line of thinking is: Say you just installed a fresh Ubuntu. What would you need to back up? Answer: nothing. You haven't changed anything yet, so you can simply reinstall Ubuntu. It restores /bin, /etc, /root, /usr, etc.



        So the only reason you might want to backup /bin is because you have changed it or added to it. So part of backing up is understanding what is where and when it is created and modified. Just know that the rest of us struggle with this too.





        *****And, although you didn't ask, one can make full disk or partition images. These take a lot of time to backup and restore and may leave your system down while that work is proceeding. And it's how I used to backup my Windows systems using Acronis. The one thing they provide you with is a partition map, and images from non-linux partitions. I now make these before I reorganize partitions, and before I test my backup restore functions.





        (I'm very open to suggestions as to how I could make this better.)






        share|improve this answer















        What you need to backup depends on your particular system*.



        So this is going to take a little work on your part to sort out. Start by figuring out what does not need to be backed up. First take a look at your root directory, and then work backwards.



        For example, cd /; ls -F gives me:



        bin/    initrd.img@      mnt/   snap/  vmlinuz@
        boot/ initrd.img.old@ opt/ srv/ vmlinuz.old@
        cdrom/ lib/ proc/ sys/
        dev/ lib64/ root/ tmp/
        etc/ lost+found/ run/ usr/
        home/ media/ sbin/ var/


        /cdrom, /media, and /mnt are mount points so don't need backup.



        /dev, /lost+found, /proc, /run, /sys and /tmp get auto re-created on reboot. [I'm guessing the links: /initrd.img@, /initrd.img.old@, /vmlinuz@, /vmlinuz.old@ get re-created on boot ubuntu reinstall (I'm not sure which).]



        On my system /root is empty (use sudo -s to open a shell as root user to view it ... be careful to exit immediately after you inspect /root.)



        /snap is also empty. Perhaps it's a mount point.



        /var contains variable data like system logging files, mail and printer spool directories, and transient and temporary files." I now back it up, except for /var/log. ref: http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/var.html)



        /bin, /boot, /lib, /lib64, and /sbin presumably will get reloaded via a reinstall of Ubuntu unless you are doing system development work or something like that. You can either back these up or rely on a fresh install to recover them.



        /home should be in it's own backup. There will be times when you will want to restore just /home.



        That leaves other changes you've made to your system in /etc, /opt, /srv, and /usr which you will want to also backup, either together or individually.



        Here are a couple of pages that might help understand these directories:



        http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/the-root-directory.html
        http://www.tldp.org/LDP/intro-linux/html/sect_03_01.html#sect_03_01_03





        A related line of thinking is: Say you just installed a fresh Ubuntu. What would you need to back up? Answer: nothing. You haven't changed anything yet, so you can simply reinstall Ubuntu. It restores /bin, /etc, /root, /usr, etc.



        So the only reason you might want to backup /bin is because you have changed it or added to it. So part of backing up is understanding what is where and when it is created and modified. Just know that the rest of us struggle with this too.





        *****And, although you didn't ask, one can make full disk or partition images. These take a lot of time to backup and restore and may leave your system down while that work is proceeding. And it's how I used to backup my Windows systems using Acronis. The one thing they provide you with is a partition map, and images from non-linux partitions. I now make these before I reorganize partitions, and before I test my backup restore functions.





        (I'm very open to suggestions as to how I could make this better.)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 17 at 8:04

























        answered Jul 22 '16 at 20:15









        Elliptical viewElliptical view

        402312




        402312













        • This is great when you're focussed on configurations and don't need the binaries, like you said they can be installed again and this is much lighter to export and than to reinstall askubuntu.com/a/55906/104223

          – CTS_AE
          Jan 17 '17 at 4:39





















        • This is great when you're focussed on configurations and don't need the binaries, like you said they can be installed again and this is much lighter to export and than to reinstall askubuntu.com/a/55906/104223

          – CTS_AE
          Jan 17 '17 at 4:39



















        This is great when you're focussed on configurations and don't need the binaries, like you said they can be installed again and this is much lighter to export and than to reinstall askubuntu.com/a/55906/104223

        – CTS_AE
        Jan 17 '17 at 4:39







        This is great when you're focussed on configurations and don't need the binaries, like you said they can be installed again and this is much lighter to export and than to reinstall askubuntu.com/a/55906/104223

        – CTS_AE
        Jan 17 '17 at 4:39













        5














        If I reinstall my desktop system, I backup




        • /etc


        • /var, I'm too lazy to exclude some sub-folders

        • /opt


        /home is on a separate partition and has a backup made every day.



        After the reinstall, I restore the parts from my backup, which I really need.



        With this strategy, all my configurations, local mails and crontab configurations are safe and I have to reinstall my needed applications only.



        My personal scripts are saved in my home folder (daily backup, remember?), therefore I don't use /usr/local.








        share|improve this answer





















        • 1





          Will it work if I backup root, that is everything?: ./

          – Suspended
          Feb 25 '16 at 13:25











        • That would be like a clone of what I'm using now.

          – Suspended
          Feb 25 '16 at 13:26
















        5














        If I reinstall my desktop system, I backup




        • /etc


        • /var, I'm too lazy to exclude some sub-folders

        • /opt


        /home is on a separate partition and has a backup made every day.



        After the reinstall, I restore the parts from my backup, which I really need.



        With this strategy, all my configurations, local mails and crontab configurations are safe and I have to reinstall my needed applications only.



        My personal scripts are saved in my home folder (daily backup, remember?), therefore I don't use /usr/local.








        share|improve this answer





















        • 1





          Will it work if I backup root, that is everything?: ./

          – Suspended
          Feb 25 '16 at 13:25











        • That would be like a clone of what I'm using now.

          – Suspended
          Feb 25 '16 at 13:26














        5












        5








        5







        If I reinstall my desktop system, I backup




        • /etc


        • /var, I'm too lazy to exclude some sub-folders

        • /opt


        /home is on a separate partition and has a backup made every day.



        After the reinstall, I restore the parts from my backup, which I really need.



        With this strategy, all my configurations, local mails and crontab configurations are safe and I have to reinstall my needed applications only.



        My personal scripts are saved in my home folder (daily backup, remember?), therefore I don't use /usr/local.








        share|improve this answer















        If I reinstall my desktop system, I backup




        • /etc


        • /var, I'm too lazy to exclude some sub-folders

        • /opt


        /home is on a separate partition and has a backup made every day.



        After the reinstall, I restore the parts from my backup, which I really need.



        With this strategy, all my configurations, local mails and crontab configurations are safe and I have to reinstall my needed applications only.



        My personal scripts are saved in my home folder (daily backup, remember?), therefore I don't use /usr/local.









        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Oct 5 '15 at 8:44

























        answered Jul 15 '15 at 5:02









        A.B.A.B.

        68.6k12168258




        68.6k12168258








        • 1





          Will it work if I backup root, that is everything?: ./

          – Suspended
          Feb 25 '16 at 13:25











        • That would be like a clone of what I'm using now.

          – Suspended
          Feb 25 '16 at 13:26














        • 1





          Will it work if I backup root, that is everything?: ./

          – Suspended
          Feb 25 '16 at 13:25











        • That would be like a clone of what I'm using now.

          – Suspended
          Feb 25 '16 at 13:26








        1




        1





        Will it work if I backup root, that is everything?: ./

        – Suspended
        Feb 25 '16 at 13:25





        Will it work if I backup root, that is everything?: ./

        – Suspended
        Feb 25 '16 at 13:25













        That would be like a clone of what I'm using now.

        – Suspended
        Feb 25 '16 at 13:26





        That would be like a clone of what I'm using now.

        – Suspended
        Feb 25 '16 at 13:26











        3














        Most people just backup their home directory: /home/$USER/. If you want to back up the configuration files and settings, those are stored in folders and files in your home directory that start with a . (dot). Make a list of packages that you use (and PPAs) and it will be easy to reinstall all your packages should you need. Or, use the command described in this comment.



        Deja Dup Backup is a great tool that comes as a default on Ubuntu. Other options include command line (rsync, rsnapshot, rdiff-backup, etc).



        Finally, to backup the whole disk as an image, check out clonezilla.






        share|improve this answer





















        • 2





          Also, in addition to what the answer psny linked to, it wouldn't hurt to create a back up of the whole /etc/ directory which stores system wide settings. If you've made some changes there, it would be helpful to have an archive to get those changes from.

          – Marcin Kaminski
          Dec 1 '12 at 15:12






        • 2





          If you have any crontabs setup, then backup /var/spool/cron too.

          – Ian Dunn
          Apr 29 '15 at 7:08
















        3














        Most people just backup their home directory: /home/$USER/. If you want to back up the configuration files and settings, those are stored in folders and files in your home directory that start with a . (dot). Make a list of packages that you use (and PPAs) and it will be easy to reinstall all your packages should you need. Or, use the command described in this comment.



        Deja Dup Backup is a great tool that comes as a default on Ubuntu. Other options include command line (rsync, rsnapshot, rdiff-backup, etc).



        Finally, to backup the whole disk as an image, check out clonezilla.






        share|improve this answer





















        • 2





          Also, in addition to what the answer psny linked to, it wouldn't hurt to create a back up of the whole /etc/ directory which stores system wide settings. If you've made some changes there, it would be helpful to have an archive to get those changes from.

          – Marcin Kaminski
          Dec 1 '12 at 15:12






        • 2





          If you have any crontabs setup, then backup /var/spool/cron too.

          – Ian Dunn
          Apr 29 '15 at 7:08














        3












        3








        3







        Most people just backup their home directory: /home/$USER/. If you want to back up the configuration files and settings, those are stored in folders and files in your home directory that start with a . (dot). Make a list of packages that you use (and PPAs) and it will be easy to reinstall all your packages should you need. Or, use the command described in this comment.



        Deja Dup Backup is a great tool that comes as a default on Ubuntu. Other options include command line (rsync, rsnapshot, rdiff-backup, etc).



        Finally, to backup the whole disk as an image, check out clonezilla.






        share|improve this answer















        Most people just backup their home directory: /home/$USER/. If you want to back up the configuration files and settings, those are stored in folders and files in your home directory that start with a . (dot). Make a list of packages that you use (and PPAs) and it will be easy to reinstall all your packages should you need. Or, use the command described in this comment.



        Deja Dup Backup is a great tool that comes as a default on Ubuntu. Other options include command line (rsync, rsnapshot, rdiff-backup, etc).



        Finally, to backup the whole disk as an image, check out clonezilla.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 13 '17 at 12:23









        Community

        1




        1










        answered Nov 27 '12 at 0:17









        philshemphilshem

        1,93011426




        1,93011426








        • 2





          Also, in addition to what the answer psny linked to, it wouldn't hurt to create a back up of the whole /etc/ directory which stores system wide settings. If you've made some changes there, it would be helpful to have an archive to get those changes from.

          – Marcin Kaminski
          Dec 1 '12 at 15:12






        • 2





          If you have any crontabs setup, then backup /var/spool/cron too.

          – Ian Dunn
          Apr 29 '15 at 7:08














        • 2





          Also, in addition to what the answer psny linked to, it wouldn't hurt to create a back up of the whole /etc/ directory which stores system wide settings. If you've made some changes there, it would be helpful to have an archive to get those changes from.

          – Marcin Kaminski
          Dec 1 '12 at 15:12






        • 2





          If you have any crontabs setup, then backup /var/spool/cron too.

          – Ian Dunn
          Apr 29 '15 at 7:08








        2




        2





        Also, in addition to what the answer psny linked to, it wouldn't hurt to create a back up of the whole /etc/ directory which stores system wide settings. If you've made some changes there, it would be helpful to have an archive to get those changes from.

        – Marcin Kaminski
        Dec 1 '12 at 15:12





        Also, in addition to what the answer psny linked to, it wouldn't hurt to create a back up of the whole /etc/ directory which stores system wide settings. If you've made some changes there, it would be helpful to have an archive to get those changes from.

        – Marcin Kaminski
        Dec 1 '12 at 15:12




        2




        2





        If you have any crontabs setup, then backup /var/spool/cron too.

        – Ian Dunn
        Apr 29 '15 at 7:08





        If you have any crontabs setup, then backup /var/spool/cron too.

        – Ian Dunn
        Apr 29 '15 at 7:08











        2














        Let's collect a list of files here. I've made this post "community wiki."



        Of course, it varies from person to person. Mine is used mainly as a web server and NFS server.



        mkdir $MY_BACKUP_FOLDER
        cd $MY_BACKUP_FOLDER


        crontabs



        sudo rsync -a --relative /var/spool/cron/crontabs .


        NFS shares



        sudo rsync -a --relative /etc/exports .


        sudoers



        sudo rsync -a --relative /etc/sudoers .


        apache config



        sudo rsync -a --relative /etc/apache2/apache2.conf .


        autofs



        sudo rsync -a --relative /etc/auto* .


        fstab



        sudo rsync -a --relative /etc/fstab .


        hosts



        sudo rsync -a --relative /etc/hosts .


        samba



        sudo rsync -a --relative /etc/samba/smb.conf .


        systemd



        mlocate



        sudo rsync -a --relative /etc/updatedb.conf .


        home dir can be preserved if you do a ubuntu reinstall






        share|improve this answer






























          2














          Let's collect a list of files here. I've made this post "community wiki."



          Of course, it varies from person to person. Mine is used mainly as a web server and NFS server.



          mkdir $MY_BACKUP_FOLDER
          cd $MY_BACKUP_FOLDER


          crontabs



          sudo rsync -a --relative /var/spool/cron/crontabs .


          NFS shares



          sudo rsync -a --relative /etc/exports .


          sudoers



          sudo rsync -a --relative /etc/sudoers .


          apache config



          sudo rsync -a --relative /etc/apache2/apache2.conf .


          autofs



          sudo rsync -a --relative /etc/auto* .


          fstab



          sudo rsync -a --relative /etc/fstab .


          hosts



          sudo rsync -a --relative /etc/hosts .


          samba



          sudo rsync -a --relative /etc/samba/smb.conf .


          systemd



          mlocate



          sudo rsync -a --relative /etc/updatedb.conf .


          home dir can be preserved if you do a ubuntu reinstall






          share|improve this answer




























            2












            2








            2







            Let's collect a list of files here. I've made this post "community wiki."



            Of course, it varies from person to person. Mine is used mainly as a web server and NFS server.



            mkdir $MY_BACKUP_FOLDER
            cd $MY_BACKUP_FOLDER


            crontabs



            sudo rsync -a --relative /var/spool/cron/crontabs .


            NFS shares



            sudo rsync -a --relative /etc/exports .


            sudoers



            sudo rsync -a --relative /etc/sudoers .


            apache config



            sudo rsync -a --relative /etc/apache2/apache2.conf .


            autofs



            sudo rsync -a --relative /etc/auto* .


            fstab



            sudo rsync -a --relative /etc/fstab .


            hosts



            sudo rsync -a --relative /etc/hosts .


            samba



            sudo rsync -a --relative /etc/samba/smb.conf .


            systemd



            mlocate



            sudo rsync -a --relative /etc/updatedb.conf .


            home dir can be preserved if you do a ubuntu reinstall






            share|improve this answer















            Let's collect a list of files here. I've made this post "community wiki."



            Of course, it varies from person to person. Mine is used mainly as a web server and NFS server.



            mkdir $MY_BACKUP_FOLDER
            cd $MY_BACKUP_FOLDER


            crontabs



            sudo rsync -a --relative /var/spool/cron/crontabs .


            NFS shares



            sudo rsync -a --relative /etc/exports .


            sudoers



            sudo rsync -a --relative /etc/sudoers .


            apache config



            sudo rsync -a --relative /etc/apache2/apache2.conf .


            autofs



            sudo rsync -a --relative /etc/auto* .


            fstab



            sudo rsync -a --relative /etc/fstab .


            hosts



            sudo rsync -a --relative /etc/hosts .


            samba



            sudo rsync -a --relative /etc/samba/smb.conf .


            systemd



            mlocate



            sudo rsync -a --relative /etc/updatedb.conf .


            home dir can be preserved if you do a ubuntu reinstall







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jun 12 '18 at 20:28


























            community wiki





            3 revs
            Sridhar-Sarnobat
























                1














                Just a reminder if you're using DejaDup (or anything else really), also exclude any cloud storage folders (likely in your home), such as Dropbox. If you're paying for s3 storage this could be a bad mistake.






                share|improve this answer




























                  1














                  Just a reminder if you're using DejaDup (or anything else really), also exclude any cloud storage folders (likely in your home), such as Dropbox. If you're paying for s3 storage this could be a bad mistake.






                  share|improve this answer


























                    1












                    1








                    1







                    Just a reminder if you're using DejaDup (or anything else really), also exclude any cloud storage folders (likely in your home), such as Dropbox. If you're paying for s3 storage this could be a bad mistake.






                    share|improve this answer













                    Just a reminder if you're using DejaDup (or anything else really), also exclude any cloud storage folders (likely in your home), such as Dropbox. If you're paying for s3 storage this could be a bad mistake.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 15 '15 at 4:13









                    kdfordkdford

                    212




                    212























                        0














                        Use Deja Dup backup. It is provided by default. Go to settings and keep only root folder (/) as "folders to include" and add media folder (/media) in "folders to ignore".



                        Because of this, all your programs will be backed up in case of system damage (rare) except your other drives which normally remain unaffected.






                        share|improve this answer




























                          0














                          Use Deja Dup backup. It is provided by default. Go to settings and keep only root folder (/) as "folders to include" and add media folder (/media) in "folders to ignore".



                          Because of this, all your programs will be backed up in case of system damage (rare) except your other drives which normally remain unaffected.






                          share|improve this answer


























                            0












                            0








                            0







                            Use Deja Dup backup. It is provided by default. Go to settings and keep only root folder (/) as "folders to include" and add media folder (/media) in "folders to ignore".



                            Because of this, all your programs will be backed up in case of system damage (rare) except your other drives which normally remain unaffected.






                            share|improve this answer













                            Use Deja Dup backup. It is provided by default. Go to settings and keep only root folder (/) as "folders to include" and add media folder (/media) in "folders to ignore".



                            Because of this, all your programs will be backed up in case of system damage (rare) except your other drives which normally remain unaffected.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 1 '12 at 15:04









                            VedValsVedVals

                            1,59162542




                            1,59162542






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Ask Ubuntu!


                                • 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%2faskubuntu.com%2fquestions%2f222326%2fwhich-folders-to-include-in-backup%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

                                flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                Mangá

                                Eduardo VII do Reino Unido