wa4chq Posted November 10, 2016 Share Posted November 10, 2016 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. Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 10, 2016 Share Posted November 10, 2016 Personally I have been using rsync to run automated backups for years now using this: https://wiki.archlinux.org/index.php/rsync#Automated_backup 2 Quote Link to comment Share on other sites More sharing options...
amenditman Posted November 10, 2016 Share Posted November 10, 2016 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. 3 Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 10, 2016 Share Posted November 10, 2016 Agreed Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 10, 2016 Author Share Posted November 10, 2016 OK...one of the articles I read said rsync was the way to go..... I'll go back and look at it. I guess I'm still learning about tar.... thanks! 1 Quote Link to comment Share on other sites More sharing options...
V.T. Eric Layton Posted November 10, 2016 Share Posted November 10, 2016 (edited) 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! Edited November 10, 2016 by V.T. Eric Layton 2 Quote Link to comment Share on other sites More sharing options...
V.T. Eric Layton Posted November 10, 2016 Share Posted November 10, 2016 Ah... my bad. Rsync does have compression capabilities (zip). See the last part of this tutorial... Â http://www.howtogeek.com/135533/how-to-use-rsync-to-backup-your-data-on-linux/ 1 Quote Link to comment Share on other sites More sharing options...
amenditman Posted November 11, 2016 Share Posted November 11, 2016 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). Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 11, 2016 Author Share Posted November 11, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 11, 2016 Share Posted November 11, 2016 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 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 11, 2016 Author Share Posted November 11, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
Hedon James Posted November 11, 2016 Share Posted November 11, 2016 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? 1 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 11, 2016 Author Share Posted November 11, 2016 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 Quote Link to comment Share on other sites More sharing options...
V.T. Eric Layton Posted November 11, 2016 Share Posted November 11, 2016 (edited) 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 November 11, 2016 by V.T. Eric Layton Quote Link to comment Share on other sites More sharing options...
Hedon James Posted November 11, 2016 Share Posted November 11, 2016 Trying to save you a little time. had a hard time finding it! linked for you: Â http://forums.scotsnewsletter.com/index.php?showtopic=67147 1 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 12, 2016 Author Share Posted November 12, 2016 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.... 1 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 14, 2016 Author Share Posted November 14, 2016 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 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 14, 2016 Author Share Posted November 14, 2016 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..... Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 14, 2016 Share Posted November 14, 2016 I know it sounds funny but it is much simpler to just use the rsync command as it is very straightforward to use. 1 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 14, 2016 Author Share Posted November 14, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
amenditman Posted November 14, 2016 Share Posted November 14, 2016 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. 2 Quote Link to comment Share on other sites More sharing options...
Hedon James Posted November 14, 2016 Share Posted November 14, 2016 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! 2 Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 14, 2016 Share Posted November 14, 2016 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. 2 Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 14, 2016 Author Share Posted November 14, 2016 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! Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 14, 2016 Author Share Posted November 14, 2016 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"!! 1 Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 14, 2016 Share Posted November 14, 2016 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. Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 14, 2016 Author Share Posted November 14, 2016 Hey securitybreach....that's what I normally do but with the luckybackup, I was copying to the clipboard via a button.... Â and center button from the mouse would not paste... Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 14, 2016 Share Posted November 14, 2016 I got that but I was saying that middle click should usually still paste what is in the clipboard. Quote Link to comment Share on other sites More sharing options...
wa4chq Posted November 15, 2016 Author Share Posted November 15, 2016 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. Quote Link to comment Share on other sites More sharing options...
securitybreach Posted November 15, 2016 Share Posted November 15, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.