LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   backing up linux (https://www.linuxquestions.org/questions/linux-newbie-8/backing-up-linux-4175560117/)

kkazia 11-28-2015 10:43 PM

backing up linux
 
Hi

I am new to linux so I would like to know how to work with partitions and backing up and restoration of Linux. Which are the best tools available for this??
I am using linux Mint

thanks

kk

crazy-yiuf 11-28-2015 11:25 PM

depends on your specific needs. it looks like the arch wiki, etc., have a large number of options.

personally i'm a command line purist, so I use parted to work with partitions. for backups, cron runs a weekly script that tars my important files and mails them to a computer in my living room. obviously, this wouldn't be appropriate for administrating a multi-user network.

a few hints if you go the scripting route:

- you can check what is using up space on your computer with sudo du -h --max-depth 1 /
an easy way to back up most of the important files is to tar and xz /home and /etc if they are small enough (though this is unlikely if you have, for example, a big .cache folder in your home directory used for your browser, etc.)

- you can run dpkg --get-selections > packages.bak to save your package selections to a file, then restore them with dpkg --set-selections.

- you can check if a file has been changed or modified before replacing it to save some space/bandwidth

donatom 11-29-2015 12:27 AM

I use rsync (comes with most Linux distros). It is super fast and you can copy your backup to a new system/partition. The partition doesn't have to be the same size or larger (as is the case with dd which is another way to backup your system).

You can learn all about its use from the archwiki website: https://wiki.archlinux.org/index.php...kup_with_rsync
You need to use terminal, but as you see the command is not that complicated. I would suggest using
Code:

# rsync -aAHXv  . . .
instead of just -aAXv because I ran into troubles with the latter: my package manager complained that there were multiple duplicate files and wouldn't work when I copied the rsync files to a partition on a laptop.

To back up your /home, you would issue another rsync command (the command mentioned above is for the entire system). Here is
an example of a /home backup:
Code:

  rsync -a --info=progress2 --exclude={"/Videos/*","/.cache/*"} /home/your-user-name/ /path/to/backup/media/
Inside the exclude= brackets you can list any directories and their subdirectories that you don't want/need to copy. "/.cache/ and its subdirectories are not necessary for a backup. My Videos directory contains a lot of videos that I play using Plex Media Server. It would require a lot of copying, and I wouldn't be upset if I lost them (I can easily repopulate the directory with other videos).

It is advisable to copy your root ("/") files separate from your /home files since if you bork your system, you would only have to use the backup for root to get it up and running again which would save you time.

It took 25 minutes to copy my root files with rsync, and 17 minutes to copy my /home files. And it took the same amount of time to copy the rsync backup files to a new partition.

Some of the info listed above comes from
http://askubuntu.com/questions/54565...seless-folders

Another possibility is to use dd to backup each of your partitions. Here is a clear explanation from Arch Wiki:
https://wiki.archlinux.org/index.php/Disk_cloning
This is a bit easier than rsync but if you are not careful (if you put the partition/path that you are copying to before the partition that you are copying from), you will have to reinstall your system.

dd comes on virtually all Linux distros.

You can also use Clonzilla which more or less guides you through the process (I believe it is a type of GUI and utilizes dd).
You would use your package manager (dnf, aptitude, apt-get, pacman, etc) to install it. It is just as time-consuming as dd is -- it can take over an hour to copy a partition.

You can use all three on any Linux distro and you can even use them on Windows and Mac.

Hope this is helpful.

TxLonghorn 11-29-2015 08:24 AM

Quote:

Originally Posted by kkazia (Post 5456698)
Hi
I am new to linux so I would like to know how to work with partitions and backing up and restoration of Linux. Which are the best tools available for this?? I am using linux Mint

The best tool for working with partitions is the Gparted program.
It is already installed on your live Linux Mint DVD or USB. However, it is not installed by default when you install Mint to the hard drive. So you have to install it with this command:
Code:

sudo apt-get install gparted
Here is a long list of tutorials for partitioning and more...

When you ask about backing up and restoring Linux, you have to be more specific. Are you thinking of backing up your operating system? Or just talking about backing up your personal data?
For backing up personal data, you can learn to use the rsync commands, or tar commands. But my personal choice is the grsync program.
Code:

sudo apt-get install grsync
With grsync, once you have it configured, you just plug in your USB backup drive, open the program and click "Run", and that's it - DONE.

kkazia 11-29-2015 09:02 AM

thank you
 
Really appreciated the feedback and will look into this thoroughly ,
kk

KernelTainted 11-29-2015 01:52 PM

Quote:

Originally Posted by kkazia (Post 5456698)
Hi

I am new to linux so I would like to know how to work with partitions and backing up and restoration of Linux. Which are the best tools available for this??
I am using linux Mint

thanks

kk

If you have an external drive the same size or slightly larger you can prepare and boot a distro called Clonezilla Live and perform Ghost-like backups of the entire system, partitions and all.

Otherwise...

For basic, frequent backups, I use a file synchronization tool and external storage. My favorite is Freefilesync, which works and looks the same in Windows as it does in my Linux distros of choice. If you can't find or install that, there are a number of front-end GUIs for rsync. grsync is pretty good. The first backup takes a long time depending on how much data you have. Subsequent backups are differential-incremental and go very fast.

For settings, I like to take my Firefox settings with me. Just show hidden files and folders in home. The hidden folder .mozilla can be copied somewhere and restored to its new home.

Additionally, as a second line of defense, make a full backup of home using duplicity and its front-end deja-dup.

For application reinstallation your package manager can save a list of current programs for one-shot reinstallation (exception->software from PPAs).

sidzen 11-29-2015 02:33 PM

+1 Clonezilla for backing up an entire drive or partition, especially once all the programs wanted are installed and configured as desired. It takes but a short time to get used to its workings and many images may be backed up on a USB device. Many times I have gone back to a stored image after a failed dist-upgrade or a screwed up system for one reason or another.

donatom 11-29-2015 04:48 PM

I noticed my example of rsync backup of /home is incomplete. I forgot to include and name the directory where the backup directories/files will be placed (otherwise they will be scattered among other files/directories).

Here is a corrected command:

Code:

# rsync -a --info=progress2 --delete --exclude={"/Videos/*","/.cache/*"} /home/name-of-user/ /path/to/backup/media/Rsync-home-backup-Dec2015/
You won't have to actually create this directory (/Rsync-home-backup-Dec2015); rsync does it for you. Just make sure you run the rsync command as super user or with "sudo". If not, rsync will stop, complaining that it lacks privileges to create directories or copy files. This is especially true when you run a full-system backup with rsync.

Notice the --delete option. You would add this option so that when you run the backup later (weekly,daily,etc.), rsync would only add/delete what has changed. Also notice that the directories that you are backing up and the directory where you are storing the backup must end in a forward slash (/).

Fred Caro 11-29-2015 08:24 PM

rsync gets my vote as it is very flexible, you might want to think about how you use the "--exclude-from=" option.
If you want restore it to a fresh install (because the original is foobared) then the new install will have its own set of . files, possibly different from those on your original, so write an exclude file to include all of those.

Fred.

kkazia 11-29-2015 08:30 PM

Thank you once again! Iwill give rsync a shot

kk

JJJCR 11-30-2015 02:04 AM

Quote:

Originally Posted by sidzen (Post 5456968)
+1 Clonezilla for backing up an entire drive or partition, especially once all the programs wanted are installed and configured as desired. It takes but a short time to get used to its workings and many images may be backed up on a USB device. Many times I have gone back to a stored image after a failed dist-upgrade or a screwed up system for one reason or another.

agree with Clonezilla, clone the machine or server with Clonezilla.

Then do rsync backup for folders that keeps updating.

If the server or machine goes south, restore the clone to a new VM or hardware then do an rsync for the latest backup and keep on going.

I used Clonezilla to clone a 10 year old server and restore to VM and works just fine.

gunetel 11-30-2015 04:30 AM

There is a backup option for my VPS, so i used that graphics user interface to back up my Linux box. I am not that a tech guy, lol

TxLonghorn 11-30-2015 05:10 AM

Quote:

Originally Posted by donatom (Post 5457018)
Also notice that the directories that you are backing up and the directory where you are storing the backup must end in a forward slash (/).

This is not correct. Here is the exact command created by grsync and used to back up my personal data from /home/dan/sdb2_data/MyStuff to /media/dan/sdd2_413gb/MyStuff
It works fine with no slashes at the end.
Code:

rsync -r -t -p -o -v --progress --delete -u -s --exclude-from=sdb2_data/MyStuff/Computing/grsync-exclude.txt /home/dan/sdb2_data/MyStuff /media/dan/sdd2_413gb

suicidaleggroll 11-30-2015 10:34 AM

Quote:

Originally Posted by TxLonghorn (Post 5457273)
This is not correct. Here is the exact command created by grsync and used to back up my personal data from /home/dan/sdb2_data/MyStuff to /media/dan/sdd2_413gb/MyStuff
It works fine with no backslashes at the end.
Code:

rsync -r -t -p -o -v --progress --delete -u -s --exclude-from=sdb2_data/MyStuff/Computing/grsync-exclude.txt /home/dan/sdb2_data/MyStuff /media/dan/sdd2_413gb

The backslash on rsync is very important. On the destination it doesn't matter, but on the source the backslash tells rsync to copy the contents of the directory, while the lack of a backslash tells rsync to copy the directory itself and its contents.

So neither using it or leaving it off is correct or incorrect, but it does change the behavior of the command, so you need to use the correct syntax for your application.

TxLonghorn 11-30-2015 12:03 PM

Yes, got it.
/home/suicidaleggroll copies /home/suicidaleggroll and all directories therein (when using -r).
/home/suicidaleggroll/ copies only all directories, but not /home/suicidaleggroll


All times are GMT -5. The time now is 01:11 PM.