LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-28-2015, 11:43 PM   #1
kkazia
LQ Newbie
 
Registered: Nov 2015
Posts: 10

Rep: Reputation: Disabled
Smile 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
 
Old 11-29-2015, 12:25 AM   #2
crazy-yiuf
Member
 
Registered: Nov 2015
Distribution: Debian Sid
Posts: 103

Rep: Reputation: 48
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

Last edited by crazy-yiuf; 11-29-2015 at 12:30 AM.
 
Old 11-29-2015, 01:27 AM   #3
donatom
Member
 
Registered: Feb 2012
Location: Southern California
Distribution: Archlinux, Debian, Fedora
Posts: 41
Blog Entries: 4

Rep: Reputation: Disabled
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.

Last edited by donatom; 11-29-2015 at 01:29 AM.
 
1 members found this post helpful.
Old 11-29-2015, 09:24 AM   #4
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 569

Rep: Reputation: 183Reputation: 183
Quote:
Originally Posted by kkazia View Post
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.

Last edited by TxLonghorn; 11-29-2015 at 09:28 AM.
 
Old 11-29-2015, 10:02 AM   #5
kkazia
LQ Newbie
 
Registered: Nov 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
Smile thank you

Really appreciated the feedback and will look into this thoroughly ,
kk
 
Old 11-29-2015, 02:52 PM   #6
KernelTainted
LQ Newbie
 
Registered: Oct 2014
Posts: 11

Rep: Reputation: Disabled
Cool

Quote:
Originally Posted by kkazia View Post
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).

Last edited by KernelTainted; 11-29-2015 at 03:07 PM.
 
Old 11-29-2015, 03:33 PM   #7
sidzen
Member
 
Registered: Feb 2014
Location: Inland PNW
Distribution: slackware & related distros
Posts: 109

Rep: Reputation: Disabled
+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.
 
1 members found this post helpful.
Old 11-29-2015, 05:48 PM   #8
donatom
Member
 
Registered: Feb 2012
Location: Southern California
Distribution: Archlinux, Debian, Fedora
Posts: 41
Blog Entries: 4

Rep: Reputation: Disabled
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 (/).

Last edited by donatom; 11-29-2015 at 05:50 PM.
 
Old 11-29-2015, 09:24 PM   #9
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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.
 
Old 11-29-2015, 09:30 PM   #10
kkazia
LQ Newbie
 
Registered: Nov 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thank you once again! Iwill give rsync a shot

kk
 
Old 11-30-2015, 03:04 AM   #11
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,102

Rep: Reputation: 181Reputation: 181
Wink

Quote:
Originally Posted by sidzen View Post
+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.

Last edited by JJJCR; 11-30-2015 at 03:05 AM. Reason: edit
 
Old 11-30-2015, 05:30 AM   #12
gunetel
LQ Newbie
 
Registered: Nov 2015
Posts: 4

Rep: Reputation: Disabled
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
 
Old 11-30-2015, 06:10 AM   #13
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 569

Rep: Reputation: 183Reputation: 183
Quote:
Originally Posted by donatom View Post
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

Last edited by TxLonghorn; 11-30-2015 at 12:56 PM.
 
Old 11-30-2015, 11:34 AM   #14
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Quote:
Originally Posted by TxLonghorn View Post
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.
 
Old 11-30-2015, 01:03 PM   #15
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 569

Rep: Reputation: 183Reputation: 183
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backing up bsds and linux methodtwo *BSD 3 03-04-2011 03:14 AM
Backing up Linux zonen Linux - Software 6 02-25-2005 10:00 AM
Backing up Linux essentials pix Debian 1 07-28-2003 07:21 AM
backing up linux kudos Linux - General 3 01-07-2003 09:27 PM
backing up linux to cd-r/rw mdjames0 Linux - Newbie 2 07-26-2002 02:34 PM


All times are GMT -5. The time now is 04:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration