Linux - What directories should I exclude when backing up a server?
When backing up a Linux server, it's important to be selective about which directories you include in your backup and which directories you exclude. The choice of directories to exclude depends on the specific needs and configuration of your server, but here are some common directories that are often excluded from backups:
/proc- This directory contains information about running processes and is a virtual file system. It does not contain real files and should be excluded from backups.
/sys- Similar to
/sysdirectory is a virtual file system that contains information about kernel and device parameters. It does not need to be backed up.
/tmpdirectory typically contains temporary files and can be excluded from backups. It's common practice to configure the
/tmpdirectory to be cleared on system boot.
/var/tmp- This directory may also contain temporary files and can often be excluded from backups.
/var/cachedirectory can store cache data, which can usually be regenerated if necessary, so it may be excluded to save backup space.
/var/log- While logs are important for system monitoring and debugging, they can grow quite large. Depending on your needs, you may choose to exclude some log files or directories within
/dev- This directory contains device files, which are recreated at boot. It's not necessary to back up device files.
/mnt- This directory is often used for temporarily mounting external devices or network shares. It may not contain critical data and can be excluded.
/media- Similar to
/mediadirectory is used for mounting removable media and may not contain critical data.
/lost+found- This directory is used by the filesystem check utility (fsck) and typically doesn't contain user data. It doesn't need to be backed up.
- Any other directories or files that are specific to your server's configuration and can be regenerated or reinstalled if necessary.
Conversely, you should include directories containing your important data, configuration files, user data, and application data in your backups. Common directories to include might be:
/etc- Contains system-wide configuration files.
/home- Contains user home directories.
/var/wwwor other web server data directories.
- Databases and their data directories (e.g., MySQL, PostgreSQL, etc.).
- Configuration files for applications and services you rely on.
Always consider the specific needs and requirements of your server and applications when deciding which directories to include or exclude from your backups. Additionally, you should maintain a backup policy that includes regular testing and validation of your backup and restoration processes to ensure your data can be recovered in case of a disaster.
Can git be used as a backup tool?
Git is primarily a version control system rather than a traditional backup tool. While it can help you manage and track changes to your source code and other text-based files, it is not designed as...Questions
Why isn’t RAID a backup
RAID (Redundant Array of Independent Disks) is a technology used to improve the performance, availability, and reliability of data storage in a computer system. While it provides certain benefits, ...Questions
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.Write for us
Build on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email@example.com
or submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github