What are "important files"?
Solution 1:
Back up documents you've created, and anything of similar importance to you.
In the context of backup advice, important files are files that are important to you--files that you do not want to lose. There are many files on your Ubuntu system that are very important to the operation of the system, but which are extremely easy to replace and thus not a priority for most users' backups. If you have heavily customized your system, then some configuration files in /etc
might be important to back up--but you would know that, having edited those files. Most users need only back up files in their home directories.
This is to say that anything you would be more than annoyed to lose is important. Usually these are files you have created, like documents, and files that would be difficult or impossible to replace, like pictures of family members if they don't exist anywhere else. Before performing actions that carry an elevated risk of data loss, you should back up whatever files that you should be backing up anyway. If you do currently have backups, make sure they are current. If you don't have backups, this is a great time to start. You don't have to back up your entire system, though that is one option.
Besides documents, most users will want to back up any personal correspondence that is not also stored and accessible elsewhere. This often includes instant messaging logs. Of course, if you don't care if you lose those logs, you need not back them up. You will likely want to back up any books, music, and videos that you cannot easily replace, but if they're easily replaceable then backing them up becomes relatively unimportant, though you might still choose to do so for convenience.
Some users strongly prefer to be able to quickly install all the packages they had installed before. If that applies to you, then you should consider following the advice about APT packages in George Mathioudakis's answer. The really important files to back up, however, are the files you would be very upset if you lost. (So for most people, the key part of that answer is the section on "personal data" at the beginning.)
Reinstalling Ubuntu is pretty easy. Replacing family pictures, or a novel you've been working on, or notes you took during an important telephone conversation, or a huge list of all the things you need to organize an upcoming event--these are the sorts of things that are usually the most important to back up.
Anything you would attempt to recover if lost, or that you would be very relieved to have backed up if you needed to get back, is an important file.
Your home directory (almost always /home/username
on Ubuntu) contains some files that are not important in this sense. But there's nothing wrong with backing up more than you need, so backing up the whole thing is a perfectly good approach.
To elaborate, here's some information about the specific issues you mentioned in your question.
1. Files in /home
that don't copy easily:
If the small handful of files that couldn't be copied when you backed up users' home directories (i.e., the subdirectories of /home
) are easily replaced, then you don't have to worry that they couldn't be copied. Since there are so few of them, you can check each one. Lock files do not need to be backed up. Unless you're actually backing up your entire drive with the intention of being able to restore the system to the exact state it was in before, you rarely need to care about lock files.
Your home directory may contain a subdirectory called .gvfs
that you can't copy due to permissions problems. You don't need that either.
2. Global configuration files /etc
:
There's probably no need to back up /etc
. It does contain some files that you can't even read as a non-root user, so if you do decide to perform a full backup of it then you will likely use sudo
to either copy or archive its contents.
3. Games and apps:
There are two things you may mean by "the files for things like games and apps."
Except under unusual situations, you don't need to back up the actual executables, data files, and documentation for games and apps. You can just reinstall them. If you've installed so much software that you can't remember what it all was, but you still want to be able to get it all back easily (rather than just installing what you still need), then I recommend backing up your APT packages as detailed in George Mathioudakis's answer. If you have software installed in other ways, that could not be restored with Ubuntu's package manager, and it would be a hassle to restore it, then you may want to back that up, but without specific details about how you installed it or what it is, I can't give advice about the best way to do that.
However, you might decide to back up configuration files and other per-user data. Most global configuration files are in /etc
--which are probably only important to back up if you've heavily modified them yourself. The files you might care about more are the ones on your home directory, so if you back that up then you're all set. Specifically--in case you want to back up just some files, or are otherwise interested--per-user configuration is usually stored in files and directories inside your home directory (/home/username
) whose names start with .
, especially the .config
directory.
Graphical file browsers don't show files that start with .
unless you tell them to (Ctrl+H). To list them with ls
you must pass the -a
or -A
flag. If you have software that is installed in your home directory--including games--and you're not sure where it is, it may be in the .local
directory. Often it's unnecessary to back that up but you may want to see what's there. The .cache
directory is for files that programs can automatically replace--though sometimes this involves downloading data, as with album cover images--so you probably don't need that, though again, there's no harm in keeping it if you like. If you want to back up savegames (to keep your progress in a video game) then you should search or consult documentation to see where they are stored for the games you care about.
4. Full system backups / deciding how much to back up and how to do it:
If you plan to do a clean install, or having to do one isn't an outcome you strongly wish to avoid, then you probably do not want to do a full system backup.
For more information on deciding what to back up, especially on deciding if it makes sense for you to back up more than "important" files, see What's a good back-up strategy for 1 desktop PC?
5. What to back up before repartitioning operations that involve /boot
:
I recommend ensuring all your documents and important files are backed up--where "important files" has the meaning described above--anytime you are about to make changes to the partition table on the drive that contains those files.
It used to be that dynamic resizing of partitions carried quite a bit of risk. These days, data loss from unanticipated technical problems is less common, though I have seen it happen. What is more common is to accidentally make a mistake while repartitioning. Therefore, it is worth making sure your backups are current (and actually exist!) before modifying your partitions in any way. It is unfortunately easy to make different changes from the ones you intended.
Data loss within /boot
itself can usually be repaired even if you haven't specifically backed up that partition (if it's a separate partition) or directory (if it's not a separate partition). For most users, it's not important to have a backup of /boot
. If you do want a backup of /boot
, you might consider doing a full backup of the entire system, such as by creating an image of the whole drive. Usually there's not much value in being able to restore /boot
if you can't restore other things along with it.
6. Restoring a separate /boot
partition:
If /boot
is not actually a separate partition on your system but is just a directory in the /
partition, then of course restoring /
will restore it too.
Otherwise, whether or not /boot
will be backed up--and restored--depends on how you "back up the drive". If you image the entire physical disk, and not just one partition, then you should be able to restore that whole image.
If you actually do want to back up /boot
then you may want to ask a separate question about that, with specific details. Although the files in /boot
are important--you need them to boot!--it's usually pretty easy to replace them. They don't have the same status as your documents or family photos.
Since this answer is about what files are "important" for backup purposes, backup schemes for /boot
are somewhat outside its scope. With that said...
You probably don't need to repartition (nor to resize partitions) at all.
It is rare that you have to expand the /boot
partition. If you have run out of space on /boot
then this usually means you have many old kernels installed, and you can just remove some. If you cannot remove them with the package manager, this process may involve deleting some files manually, but it is still faster and easier then repartitioning.
As bodhi.zazen suggests, please take a look at My /boot partition hit 100% and now I can't upgrade. Can't remove old kernels to make room. If that doesn't describe the problem you're having or otherwise doesn't help you, and searching doesn't reveal another question that does, then I recommend posting a new question about the specific problem you are having that you fear may require you to resize your partitions. It's possible that doing so will be a reasonable or even ideal solution to your problem, but quite likely that your problem will better solved through other means.
Solution 2:
Backing up Personal Data:
rsync --progress /home/'user' /path/to/user/profile/backup/here
Restoring Personal Data:
rsync --progress /path/to/user/profile/backup/here /home/'user'
(Replace user
with your username.)
Back up your apt packages:
dpkg --get-selections > ~/Package.list
sudo cp -R /etc/apt/sources.list* ~/
sudo apt-key exportall > ~/Repo.keys
Restore your apt packages:
sudo apt-key add ~/Repo.keys
sudo cp -R ~/sources.list* /etc/apt/
sudo apt-get update
sudo apt-get install dselect
sudo dselect update
sudo dpkg --set-selections < ~/Package.list
sudo apt-get dselect-upgrade -y
(Due to a Debian bug, before sudo dpkg --set-selections < ~/Package.list
you may have to do this):
apt-cache dumpavail > ~/temp_avail
sudo dpkg --merge-avail ~/temp_avail
rm ~/temp_avail
(I personally had to run the above commands when restoring.)
These made my life easier when formatting. I've used these commands twice and saved me a lot of time. Hope I helped.