Jump to content

Trying to understand how to do a simple backup


wa4chq

Recommended Posts

Godd afternoon!

First off, what I'm trying to do is learn a little bit about backing up files. I found something this morning that uses the tar command:

# tar -cvpzf /BackupDirectory/backupfilename.tar.gz /ImportantData/directory/path

What I'd like to be able to do is to have a script that would run every time I boot and back up files in my /home directory to a memory card that I keep plugged in. The memory card is mounted each time I boot. I found the code above in an article I read. He includes a simple script that would run as a cron job. I've tested the code above using examples to see if it would back up a file and put it on the memory card and it does. But what I want to be able to do is back up without duplicating directories/files each time the script is run.

Here is the link to the article I read:

http://broexperts.co...-tar-cron-jobs/

I've read the man pages for tar but if I understand what I read, I can't catenate or append unless the tar file is already there. In other words this won't work:

tar --catenate -cvf bama.tar bama.txt

if bama.tar doesn't exist.

I hope I'm making sense. Clear as mud I bet! I could use some suggestions or links and would rather not have solutions. I'll save that request for last, assuming I can't work it out. Tar might not be the way to go to do what I want. Another site I saw talked about using

rdiff-backup

rsync

but I don't have either one installed (yet). Thanks you guys. Have a great afternoon.

Link to comment
Share on other sites

For what you are doing I would use rsync. It will run from a script, won't duplicate any files, will update them if they change.

You can backup a single file/directory up to your entire install.

  • Like 3
Link to comment
Share on other sites

V.T. Eric Layton

My backup scheme for quite a while was rsync (manually run) from my /sda drive to my matching identically partitioned /sdb drive. This worked very well for me till my backup drive failed. :(

 

I preferred to do my backups manually because my systems do not have AC power when not in use. In other words, I shut down completely (using power strip switch) whenever my systems are not in use. If you don't shut down like I do, then the combination of cron/rsync is the way to go.

 

There're a lot of fancy-schmancy backup solutions out there, but good ol' rsync is simple, foolproof, and 100% reliable. The ONLY issue you may have is that rsync does not compress files. The data on your backup drive will be identical bit for bit as that on your primary drive, hence my use of matching identically partitioned drives. You don't need matching drives, though; I just happened to have the pair when I started doing this. Your back up drive MUST be the same capacity or larger than your primary drive.

 

Anywho, hope that helped a bit. Have FUN! :w00t:

Edited by V.T. Eric Layton
  • Like 2
Link to comment
Share on other sites

rsync can use tar and untar as part of the process.

 

The source and target do NOT need to be exactly matched in size, but the target needs to have enough capacity to store the data synced (could actually be smaller with the use of compression but final size will vary based upon what you are trying to shrink).

Link to comment
Share on other sites

Thanks again for the info about rsync. Because I never really looked into way to do a proper back up, I would just grab a flash drive and every once in a while start backing up stuff like passwds or config files, photos etc. The problem is after a while I have the same stuff backed up many times over. So I was wasting space on the flash drive. I have a hard drive from an old laptop that I could use to store stuff. I'll check out the tutorial on howtogeek....thanks you guys.

  • Like 1
Link to comment
Share on other sites

securitybreach

As per the archwiki link above, It's pretty straightforward to setup. Here is what I use (via crontab):

 

00 15 * * * rsync -ar ~/Videos /Various/Music ~/Documents ~/Downloads ~/Pictures ~/Shared ~/scripts/ /MEDIA &> /dev/null

 

I have it set so that everyday at 12:15am rsync backs up ~/Videos, /Various/Music, ~/Documents, ~/Downloads, ~/Pictures, ~/Shared and ~/scripts onto another driver mounted as /MEDIA. Anything deleted on the folders that are backed up are also deleted on the backup location (/MEDIA/) as well. Hope that makes sense :)

Link to comment
Share on other sites

OK, it turns out rsync is already on my Slackness, so I went to SlackBuilds and found grsync and installed that. I think for starters, I'd like to use a gui for rsync until I understand what's going on. So then I found this...

https://www.sit.auckland.ac.nz/Rsync_and_Grsync_Backups_for_Linux

which will be helpful. I like the section he talks about regarding the exclusion list. Anyway, I'll be playing with this a will report back with results.

Have a great day and thanks to the vets out there.

  • Like 1
Link to comment
Share on other sites

If you're using a GUI frontend for rsync, I wrote a tutorial awhile back on LuckyBackup, which is stickied on this site somewhere. LuckyBackup is just a gui frontend for rsync. Not sure if it was initiation rites (or harmless hazing?!), but it was a very comprehensive tutorial (IMO) for the uninitiated! Maybe there's something in there that will help?

  • Like 1
Link to comment
Share on other sites

Thanks securitybreach and hedon james. SB, that does look pretty straightforward. Will try it. Thanks.... Hedon James, before I saw your post, I installed a gui for rsync but I'll check yours out as well as the tutorial. Thanks

Link to comment
Share on other sites

V.T. Eric Layton

Something to be aware of using rsync/grsync, Neil...

 

If you're creating an exact copy of a partition of a main drive onto a secondary or backup drive, you must use a following / after your location of your source. Like this...

 

source: /dev/sda1/ --> destination: /dev/sdb1

 

If you forget to do this, rsync will copy your /dev/sda1 partition data into a separate directory on the backup drive. Instead of having:

 

/dev/sda1 backup on /dev/sdb1, you'll have /dev/sdb1//dev/sda1

 

If you want an identical backup that is bootable just as your main OS drive, then the added directory will prohibit this.

 

If you're just interested in backing up individual files/directories, then the above won't matter/apply to you.

 

Happy Veteran's Day and have a wonderful weekend!

 

 

 

 

 

 

 

 

 

.

Edited by V.T. Eric Layton
Link to comment
Share on other sites

Thanks for the info, Eric....right now I'm only interested in saving individual files/directories. At some point, I'd like to backup my /home directory from Archbang and Slackware.....but that will be something to mess with further down the road.

Have a good one.

 

hey thanks, hendon james! Got it bookmarked!

have a good one....

  • Like 1
Link to comment
Share on other sites

OK, I'm giving both grsync and luckybackup a test run. They both seem to work well but I'm still confused about what I want and don't want backed up. I tried making an exclude.txt like shown in several of the sites for grsync but when I run the program, it still copies everything! What I did when trying luckybackup (and I'm sure grsync would be the same) is just run what I do want to backup, one at a time.... But I'm getting stumped about doing multiple tasks. If I wanted to backup my /home directory but not stuff like .thumbnails or .cache or .mutt or /pictures /music etc I know I should be able to do that and not have to do it individually for each thing I want to save.... I'm still doing some searching and reading so I'm not asking for solutions....yet. :) I haven't finished reading the LB tutorial so my answers could be there.

signed, Not Giving Up Yet

have a good morning

Link to comment
Share on other sites

I haven't finished reading the LB tutorial so my answers could be there.

Well, I discovered the user defined template in the Exclude tab on Luckybackup. Hmmmm...I may be on to something..... :)

Link to comment
Share on other sites

Hey Securitybreach... that's what I'm seeing from some of the stuff I'm reading but in some articles that use a gui and templates I see where they let you view the command line terminal entry showing what the rsync command with all the options will be etc. if your are excluding a bunch of stuff. The command looks mighty long! But I will definitely look into just running rsync. Thanks

  • Like 1
Link to comment
Share on other sites

Excluding is simple in rsync.

 

--exclude=PATTERN
   This option allows you to selectively exclude certain files from the list of
   files to be transferred.
   This is most useful in combination with a recursive transfer.
   You can use as many --exclude options on the command line as you like to
   build up the list of files to exclude.
   See the section on exclude patterns for information on the syntax of this option.
--exclude-from=FILE
   This option is similar to the --exclude option, but instead it adds all exclude
   patterns listed in the file FILE to the exclude list.
   Blank lines in FILE and lines starting with ';' or '#' are ignored.

  • Like 2
Link to comment
Share on other sites

Hey Securitybreach... that's what I'm seeing from some of the stuff I'm reading but in some articles that use a gui and templates I see where they let you view the command line terminal entry showing what the rsync command with all the options will be etc. if your are excluding a bunch of stuff. The command looks mighty long! But I will definitely look into just running rsync. Thanks

 

SB told me that too! And maybe he's right, but I'm not there yet. I'm perfectly happy using a GUI with checkboxes, pull-down menus, and fill-in-the-blanks. Now that you've got a choice, use what works for ya! IMO, the simple act of "backing up" is more important than how you did it. Just BACKUP dude! B)

  • Like 2
Link to comment
Share on other sites

securitybreach

Just remember, you can have commands run automatically a lot easier than you can with a graphical client. I haven't had to touch my rsync cronjob in years as it just works without me even thinking about it or remembering to run it.

  • Like 2
Link to comment
Share on other sites

Thanks for the info you guys. I imagine whatever I use, once it's setup the way I want I will just let it do its things. It's kinda fun messing with this....I just hope I don't end up hosing something before it's backed up! :)

Link to comment
Share on other sites

rsync -h --progress --stats -r -tgo -p -l -D --update /home/wa4chq/sails /media/

I just found out how to copy the command to the clipboard with luckybackup using "validate". The only problem I have is getting it to paste to the cli..... just found about "shift + insert"!!

  • Like 1
Link to comment
Share on other sites

securitybreach

Just hightlight the text and mouse middle-click (press down on wheel) your mouse to paste. Works in the gui and 99.9% of the terminals.

Link to comment
Share on other sites

Hey securitybreach....that's what I normally do but with the luckybackup, I was copying to the clipboard via a button....

 

luckybackup.jpg

and center button from the mouse would not paste...

Link to comment
Share on other sites

Hey SecurityBreach..... yes, I thought the same but it doesn't, at least not for me. But the shift+insert takes care of that....if now only I remember! :) I'm using spectrwm and have set up hot keys for several actions and luckily the shift+v wasn't one of them. :)

have a good morning. Gotta continue reading about rsync etc. before work. :(

Link to comment
Share on other sites

securitybreach

Hey SecurityBreach..... yes, I thought the same but it doesn't, at least not for me. But the shift+insert takes care of that....if now only I remember! :) I'm using spectrwm and have set up hot keys for several actions and luckily the shift+v wasn't one of them. :)

have a good morning. Gotta continue reading about rsync etc. before work. :(

 

Understand and good morning to you too.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...