LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-28-2011, 09:42 AM   #1
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Rep: Reputation: 49
What is the quickest and safest way to backup my root & home partitions?


Hello:

I would like to attempt creating a cron job to backup my root (/dev/sda1) & home (/dev/sda3) partitions to an external USB drive.

I have been using Clonezilla to make image backups but, I have to physically do it, when I remember or have the time.

I have also created image backups by running:
Code:
dd if=/dev/sda1 of=/media/bkup/rootsda1.img bs=64k
dd if=/dev/sda3 of=/media/bkup/homesda3.img bs=64k
I have these questions:
  1. Should it be an 'image' backup or simply a 'file' backup?
  2. What would be the best way to do this: rsync, dd, something else?

For example, if I trash my installation, (i.e. do something that I can't figure out how to reverse) I'd like to be able to re-format /dev/sda1 to ext4 and then restore my 'most recent set of unscrewed up by rob' files.

I have never created a cron job, and worse, I have never created a .sh file which, I think, is what I need to do.

Any input on this lofty plan would be appreciated.

Last edited by Robert.Thompson; 07-28-2011 at 09:44 AM. Reason: typo
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-28-2011, 10:13 AM   #2
gazj
Member
 
Registered: Oct 2010
Location: Cambs, England, UK
Distribution: Slackware 14
Posts: 33

Rep: Reputation: 6
To backup a set of files i.e home
Code:
tar cf /mnt/sparehd/homesda3.tar.gz /home
you can schedule tasks using cron as root

Code:
crontab -e
then edit crontab i.e to backup at midnight

Code:
0 0 * * * /bin/tar -cf /mnt/sparehd/homesda3.tar.gz /home
read "man tar" and man "crontab" for more info
 
2 members found this post helpful.
Old 07-28-2011, 10:14 AM   #3
bassplayer69
Member
 
Registered: Jul 2007
Location: In a van down by the river...
Distribution: MX Linux 21
Posts: 237

Rep: Reputation: 56
There are a ton of ways to do it, but I use something very simple:

Code:
# find /home | cpio -ocv | gzip >/media/disk/backups/home-{date}.cpz
then just the opposite to restore:

Code:
# cat /media/disk/backups/home-{date}.cpz | gzip -d | cpio -icvdum
Where /media/disk is a USB external hard drive.

Last edited by bassplayer69; 07-28-2011 at 10:15 AM.
 
2 members found this post helpful.
Old 07-28-2011, 10:27 AM   #4
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
If you want to automate with cron, then the external USB drive needs to be connected when the cron job executes.

Quote:
Should it be an 'image' backup or simply a 'file' backup?
There are many ways to perform a backup. I suspect you will receive many answers. I prefer files rather than images.

Quote:
What would be the best way to do this: rsync, dd, something else?
I have been using rsnapshot for a few years. I use a layered backup approach. I have two hard drives installed. Every three hours I run rsnapshot through cron and I backup all important user files and system configuration files. Because the hard drive is inside the case, this layer of backup is to protect my system from me. If the case is stolen or damaged those backups will not help me, but I have used those backup many times to recover from "fat thumb syndrome."

Every week I perform a manual backup of the entire system. I again use rsnapshot but I use a shell script to start the process. I use a different rsnapshot configuration file. I store that hard drive in a small fire-proof safe.

I have several additional computers here. They are not primary systems. Those systems are static. If they are powered on when my backups are run every three hours, system configuration files get updated to my primary system. I use rsnapshot to backup those systems and a different rsnapshot config file.

Every month I send myself an email to perform a manual backup of those systems. Basically I power on the "remote" systems and run my shell script. Because rsnapshot uses rsync and hard links, and those systems are static, the backups take less than 15 minutes total.

I like rsnapshot because of the way rsync and hard links are used. I have more than six months of backups on a single 750 GB hard drive, which includes backups of all systems here. Without rsnapshot I'd be able to hold only about two backups on the disk.

I have used the backups to recover files or compare previous versions of scripts, etc. Worked great every time.

You can read more here:

A Backup Strategy
 
5 members found this post helpful.
Old 07-28-2011, 12:36 PM   #5
dimm0k
Member
 
Registered: May 2008
Location: Brooklyn ZOO
Distribution: Slackware64 14.2
Posts: 564

Rep: Reputation: 56
Thanks for the extra ideas and the link Woodsman! One of the things I was always wondering was how to protect my backups from fire/flood...
 
Old 07-28-2011, 01:24 PM   #6
Mike_M
Member
 
Registered: Mar 2011
Location: California
Distribution: Slackware
Posts: 116

Rep: Reputation: 53
Quote:
Originally Posted by Robert.Thompson View Post
Hello:

I would like to attempt creating a cron job to backup my root (/dev/sda1) & home (/dev/sda3) partitions to an external USB drive.

I have been using Clonezilla to make image backups but, I have to physically do it, when I remember or have the time.

I have also created image backups by running:
Code:
dd if=/dev/sda1 of=/media/bkup/rootsda1.img bs=64k
dd if=/dev/sda3 of=/media/bkup/homesda3.img bs=64k
I have these questions:
  1. Should it be an 'image' backup or simply a 'file' backup?
  2. What would be the best way to do this: rsync, dd, something else?

For example, if I trash my installation, (i.e. do something that I can't figure out how to reverse) I'd like to be able to re-format /dev/sda1 to ext4 and then restore my 'most recent set of unscrewed up by rob' files.

I have never created a cron job, and worse, I have never created a .sh file which, I think, is what I need to do.

Any input on this lofty plan would be appreciated.
In addition to what others have said, you may want to look at the native dump and restore utilities for the filesystem you use. You don't specifically state what you are currently using, but you mention ext4. I have no idea if dump/restore support ext4. One of the reasons I use XFS is because of the excellent native backup utilities, xfsdump and xfsrestore. The man pages for those tools give decent examples of how to do incremental backups. For doing filesystem backups I see no reason to look beyond the native tools provided by your filesystem. The output can be piped through SSH to provide remote backups and restores, and piped through gzip/bzip2/xz/etc. for compression.

I would avoid using dd for automated backup purposes. It doesn't take free space in to account, and you need to restore to a filesystem that is the same size or larger than the source (including free space).
 
3 members found this post helpful.
Old 07-29-2011, 07:59 AM   #7
Robert.Thompson
Member
 
Registered: Nov 2009
Location: Montreal, Quebec, Canada
Distribution: LinuxMint 20 Cinnamon
Posts: 589

Original Poster
Rep: Reputation: 49
Thanks for the input.

I am still a bit confused by 'terminology', I think.

Clonezilla or dd to an 'image' requires that the 'restore' be made to a partition of equal or greater size, right?

Is it possible, and safe, to backup just the files (is that what is meant by 'native' backup?, dump & restore?) and then restore them to a smaller or larger partition and still have a working system?

I am talking about root and home of my Slackware 13.37 system.

If I have the terminology right, which is the safest or best: image backup or dump & restore? If they are equally safe, what is the difference & why choose one over the other?

Thanks for any clarification,
 
Old 07-29-2011, 05:32 PM   #8
gorillus
Member
 
Registered: Jun 2011
Location: /home
Distribution: Slackware
Posts: 31

Rep: Reputation: 16
I use rsync. It saved my ass more than 1 time

https://wiki.archlinux.org/index.php...kup_with_rsync

It is simple and after the first time it only saves the changes. Also you can always restore single files...

You can save the backup just in a file, but I wouldn't use the root-partition for this, but with a live CD you can restore almost everything :-D

I also think it is saver, because if an image gets damaged, everything is lost...
 
2 members found this post helpful.
Old 07-29-2011, 05:59 PM   #9
Mike_M
Member
 
Registered: Mar 2011
Location: California
Distribution: Slackware
Posts: 116

Rep: Reputation: 53
Quote:
Originally Posted by Robert.Thompson View Post
Thanks for the input.

I am still a bit confused by 'terminology', I think.

Clonezilla or dd to an 'image' requires that the 'restore' be made to a partition of equal or greater size, right?
I've never used Clonezilla, so I can't speak for it. However, when doing something along the lines of

Code:
dd if=/dev/some_partition of=/path/to/some/image_file
you are doing a bit-by-bit copy of that partition. This includes free space, which is why you need to restore (dd if=/path/to/some/image_file of=/dev/some_partition) to a disk or partition of equal or greater size. It also takes a long time.

Quote:
Originally Posted by Robert.Thompson View Post
Is it possible, and safe, to backup just the files (is that what is meant by 'native' backup?, dump & restore?) and then restore them to a smaller or larger partition and still have a working system?
Yes, it is possible and safe to backup just files and then restore them. There are many ways to do this. A filesystem's native dump and restore utilities (xfsdump and xfsrestore in my case) will back up the files and directories; maintain permissions, links, etc.; and possibly have more advanced features such as incremental backups/restores. You could also use cp or tar combined with gzip/bzip2/xz/etc to maintain compressed backups of your files and directories. The man pages of cp and tar should be closely examined to find the command line switches used for your specific needs (permissions, following links, excluding files, and so on). If what you want to do is backup complete filesystems, I would strongly encourage you to look in to native tools provided by the filesystem for the job.

Quote:
Originally Posted by Robert.Thompson View Post
I am talking about root and home of my Slackware 13.37 system.

If I have the terminology right, which is the safest or best: image backup or dump & restore? If they are equally safe, what is the difference & why choose one over the other?

Thanks for any clarification,
Unless I missed it somewhere, you still haven't stated specifically what filesystem you use for your / and /home partitions. My own personal preference is using the dump and restore tools for the filesystem I use. After all, they are made for the job, and probably do it quite well. If you are using ext4 then you will need to figure out if the extfs dump and restore tools even support ext4. If they don't, then that obviously won't be an option for you. They did not when ext4 was new, but I have no idea what the current state is, as I don't use that fs.

Additionally, the term "image" can mean different things. Backup tools may make what they call an image of your partition. That could be anything, from a compressed copy certain files, to a bit-by-bit copy such as done by dd. So it isn't as simple as either an image or using a filesystem specific dump tool. There are many ways to skin this cat.
 
3 members found this post helpful.
Old 07-29-2011, 06:03 PM   #10
igadoter
Senior Member
 
Registered: Sep 2006
Location: wroclaw, poland
Distribution: many, primary Slackware
Posts: 2,717
Blog Entries: 1

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
Both backups are needed. Saving image of a partition protects your system. From other hand it may be impossible to restore the image in the way you get a working system - eg. restoring on a different computer (or the same but with a different hardware setting) may be an obstacle.
So you need to make a backup of your files using cpio or simple tar+gz.
 
1 members found this post helpful.
Old 07-30-2011, 01:02 PM   #11
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 998

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
I use rsync to backup the files in my home directory.

rsync is great because it works incrementally - rsync'ing to an empty directory takes a long time, but subsequent rsync's with only a few differences are very quick. rsync will be much faster than an image copy.

I don't find a need to back up the root directory. Instead, I re-install the OS from the DVD if that ever becomes necessary. Almost all OS re-installs are to upgrade rather than to correct for pilot error.
Ed
 
1 members found this post helpful.
Old 07-30-2011, 01:31 PM   #12
Plutonium
LQ Newbie
 
Registered: Jan 2006
Location: Sweden
Distribution: Slackware
Posts: 12

Rep: Reputation: 2
I'll use rsync and love it and I use this little bash script that cron runs once a day.

Code:
#!/bin/bash

# This script does personal backups to a rsync backup server. You will end up
# with a 7 day rotating incremental backup. The incrementals will go
# into subdirectories named after the day of the week, and the current
# full backup goes into a directory called "current"
# tridge@linuxcare.com

# directory to backup
BDIR=/home/user

# excludes file - this contains a wildcard pattern per line of files to exclude
EXCLUDES=/home/user/backup_exclude.txt

# the name of the backup machine
BSERVER=192.168.9.10

# your password on the backup server
export RSYNC_PASSWORD=****


########################################################################

BACKUPDIR=`date +%A`
#BACKUPDIR="Sunday"

OPTS="--force --delete-excluded --exclude-from=$EXCLUDES
      --delete --backup --backup-dir=/Workstation/$BACKUPDIR -av"

export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# the following line clears the last weeks incremental directory
[ -d $HOME/emptydir ] || mkdir $HOME/emptydir
rsync --delete -a $HOME/emptydir/ backup@$BSERVER::backup/Workstation/$BACKUPDIR/
rmdir $HOME/emptydir

# now the actual transfer
rsync $OPTS $BDIR backup@$BSERVER::backup/Workstation/current
And all this gives you:
ls backup/Workstation
Friday Monday Saturday Sunday Thursday Tuesday Wednesday current
 
1 members found this post helpful.
Old 07-30-2011, 02:06 PM   #13
gorillus
Member
 
Registered: Jun 2011
Location: /home
Distribution: Slackware
Posts: 31

Rep: Reputation: 16
I always rsync everything (also root). It soooo fast :-D and you can always recover root with 'chroot' - The imo most important tool for recovering a lost system.

Last edited by gorillus; 07-30-2011 at 02:08 PM.
 
1 members found this post helpful.
  


Reply



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
[SOLVED] Advice on best / safest way to capture root password grail Programming 26 06-21-2011 04:40 PM
Question on creating more partitions than default ones, i.e. /home,/root partitions casmac SUSE / openSUSE 1 12-20-2006 05:02 PM
Resizing root and /home partitions sas_tk SUSE / openSUSE 3 11-27-2006 10:01 PM
How much space for root & home? oomfoofoo Linux - Laptop and Netbook 5 08-12-2005 03:22 PM
Seperate Partitions for /usr & /home? Jukas Debian 6 03-24-2005 10:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:47 AM.

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
Open Source Consulting | Domain Registration