linux如何备份内容
If you have a home server powered by Linux, you’ll probably be upgrading your OS every so often. Here are some important files to back up and some alternative utilities that will help you get up and running quickly.
如果您有一台由Linux驱动的家庭服务器,那么您可能会经常升级您的操作系统。 这里是一些重要的文件备份和一些替代的实用程序,可以帮助您快速启动和运行。
Of course, every home server is going to be a little different, and you should adjust these recommendations accordingly—it’s just a general guide to help you understand where to start.
当然,每个家庭服务器都会有所不同,您应该相应地调整这些建议,它只是帮助您了解从何入手的一般指南。
Image by daryl_mitchell
图片来自daryl_mitchell
/家 (/home)
Let’s start with the obvious. /home contains a folder for each user on your system. Your personal home directory is where all of your music, movies, pictures, and documents are (unless you use a separate partition for them), but it also houses configuration files for your other programs. Hit ctrl+H in nautilus to show hidden files and you’ll see a slew of them! Back up whatever you need. It’s not a bad idea to back this directory up even if you have a separate /home partition, as reinstalling may overwrite a small number of these configuration files. Repeat the process for all users.
让我们从显而易见的地方开始。 / home包含系统上每个用户的文件夹。 您的个人主目录是您所有音乐,电影,图片和文档所在的目录(除非您为它们使用单独的分区),但是它还包含其他程序的配置文件。 在nautilus中按ctrl + H可以显示隐藏文件,您会看到其中的许多文件! 备份所需的任何内容。 即使您有单独的/ home分区,也要备份此目录,这不是一个坏主意,因为重新安装可能会覆盖少量的这些配置文件。 对所有用户重复该过程。
Apt来源 (Apt Sources)
The list of software sources used by apt is located at “/etc/apt/sources.list” and the signed gpg keys are in the /etc/apt/sources.list.d/ directory. If you’ve used Linux at all, you’ve likely installed software from other repositories than just the defaults. After you reinstall, you may just have to change the final distro marker to the newer one (e.g. “lucid” to “maverick”) and copy those lines to your new sources.list, but for many repositories you’ll have to download a new gpg key before you can use them. At the very least, it will at least serve as a reminder of what you had on your old setup. Ubuntu-Tweak offers a way to install software and repositories, as well as change loads of settings, and serves as an excellent alternative to this backup.
apt使用的软件源列表位于“ /etc/apt/sources.list”中,已签名的gpg**位于/etc/apt/sources.list.d/目录中。 如果您完全使用过Linux,则可能已从其他存储库安装了软件,而不仅仅是默认存储库。 重新安装后,您可能只需要将最终发行版标记更改为较新的发行版标记(例如,从“ lucid”更改为“ maverick”)并将这些行复制到新的sources.list,但是对于许多存储库,您必须下载一个您必须先使用新的gpg**。 至少,它至少可以提醒您旧设置的内容。 Ubuntu-Tweak提供了一种安装软件和存储库以及更改设置负荷的方法,并且是此备份的绝佳替代方案。
Samba配置 (Samba Configuration)
If you set up Samba (Windows) shares, then you’ll need to copy “/etc/samba/smb.conf”. Samba’s configurations change very little between versions, so you can just use your old copy after reinstalling it. If you need to reconfigure it or forget to back it up, gadmin-samba (for Gnome) and KSambaPlugin (for KDE) both provide a GUI editor for smb.conf that makes it easier to edit and redo.
如果设置了Samba(Windows)共享,则需要复制“ /etc/samba/smb.conf”。 Samba的配置在版本之间变化很小,因此您只需在重新安装后使用旧副本即可。 如果您需要重新配置它或忘记备份它,则gadmin-samba(对于Gnome)和KSambaPlugin(对于KDE)都为smb.conf提供了GUI编辑器,使编辑和重做变得更加容易。
SSH协议 (SSH)
If use SSH to remotely access your computer, you may want to save time by backing up its configuration files, located at “/etc/ssh/ssh_config” and “/etc/ssh/sshd_config”.
如果使用SSH远程访问您的计算机,您可能希望通过备份位于“ / etc / ssh / ssh_config”和“ / etc / ssh / sshd_config”中的配置文件来节省时间。
fstab (fstab)
The file in question is “/etc/fstab” and its job is to be Linux’s file system table. Make no mistake, you will NOT be able to use your old installation’s fstab file on your new installation. This is because UUIDs change anytime you reformat a partition. However, you can copy the rest of the line in your old fstab file so that you don’t have to spend time looking up all of the options. This is really useful if you have a lot of partitions, auto-mounted shares, a separate /home partition, etc. You can also use pySDM (Gnome) or mountmanager (KDE), as both provide a GUI process to edit your fstab file, but be sure to do a manual backup yourself first. From most accounts around the ‘net, it seems safest to learn about the options in fstab and edit it manually, so keep that in mind.
有问题的文件是“ / etc / fstab”,其工作将是Linux的文件系统表。 没错,您将无法在新安装上使用旧安装的fstab文件。 这是因为UUID在您重新格式化分区时会随时更改。 但是,您可以将其余的行复制到旧的fstab文件中,这样您就不必花费时间查找所有选项。 如果您有很多分区,自动挂载的共享,单独的/ home分区等,这将非常有用。您还可以使用pySDM(Gnome)或mountmanager(KDE),因为两者都提供了GUI流程来编辑fstab文件,但请务必先进行手动备份。 从网上的大多数帐户来看,了解fstab中的选项并手动进行编辑似乎是最安全的,因此请记住这一点。
备份程序 (Backup Programs)
If you have your server set up to do automatic backups with tools like rsync or Simple Backup, then you’ll want to grab their configuration files. Rsync’s config is location at “/etc/rsyncd.conf” and Simple Backup’s is at “/etc/sbackup.conf”.
如果您已将服务器设置为使用rsync或简单备份之类的工具进行自动备份,则需要获取其配置文件。 Rsync的配置位于“ /etc/rsyncd.conf”,而简单备份的位于“ /etc/sbackup.conf”。
网站档案 (Website Files)
Many people have Apache, MySQL, and/or PHP installed on their home servers to run personal websites. While their configuration files can be a little too complicated to back up, you shouldn’t forget to do it for your website itself, located in “/var/www”.
许多人在其家庭服务器上安装了Apache,MySQL和/或PHP,以运行个人网站。 尽管它们的配置文件可能有点太复杂而无法备份,但您不应忘记为您的网站本身(位于“ / var / www”中)进行备份。
You’re probably better off reconfiguring Apache, MySQL, and PHP when you reinstall them, as their versions can change and you may want to use newer passwords. When you go to do that, you can easily install all three in one-shot in Ubuntu with the following command:
重新安装Apache,MySQL和PHP时,最好重新配置它们,因为它们的版本可能会更改,并且您可能想使用较新的密码。 当您执行此操作时,可以使用以下命令在Ubuntu中轻松地一次性安装所有三个:
sudo apt-get install lamp-server^
须藤apt-get install lamp-server ^
And yes, that caret (^) needs to be there. Don’t forget to install phpMyAdmin to easily configure your MySQL databases!
是的,那个插入号(^)必须存在。 不要忘记安装phpMyAdmin来轻松配置您MySQL数据库!
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
须藤apt-get install libapache2-mod-auth-mysql phpmyadmin
You’ll need to hit the spacebar when you select your Apache installation. You’ve done it properly if see an asterisk (*) come up next to it. And, as always, make sure you change all of the default passwords for everything. Happy re-installing!
选择Apache安装时,您需要按空格键。 如果看到旁边有一个星号(*),则说明您已正确完成操作。 而且,一如既往,请确保更改所有内容的所有默认密码。 重新安装愉快!
翻译自: https://www.howtogeek.com/howto/35876/how-to-choose-what-to-back-up-on-your-linux-home-server/
linux如何备份内容