Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
02-02-2016, 07:25 PM
|
#16
|
Member
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702
|
One of the coolest things about rsync is that you can test run it. Add --dry-run to your command, and it will show you what the result will be without actually making any changes.
If you approve of the results, you can then run it again without --dry-run
Code:
cd ~ && rsync -avz --dry-run . /path/to/save/to/ --delete --log-file=/path/to/report.rpt
Personally, I use grsync - the GUI program. After it is configured the way you want, it only takes a couple of clicks to do your backup.
|
|
1 members found this post helpful.
|
02-02-2016, 09:43 PM
|
#17
|
Member
Registered: Jan 2006
Location: USA
Distribution: Mint
Posts: 90
Original Poster
Rep:
|
Thanks TXLonghorn! I wonder why you guys don't need "sudo" and I do? I didn't use the "CD ~ &&" because Mint 17.3 Mate automatically puts you in your home directory as soon as you open the terminal. Ill take a look at grysnc. Maybe that will work. None of the others have after the first aborted run. But the command line seems to be working so far without error and I am up to 200 gigabytes.
OK I ran grsync. It was already on my computer but it said "synchronize files with rsync" Since I had no idea what that meant I left it alone and forgot all about it. But I did a simulate from the GUI and it ran like a charm without errors. Hopefully it will also run the second time! Thanks very much. I may be installing a new hard drive this weekend!!
Last edited by Mikech; 02-02-2016 at 09:55 PM.
|
|
|
02-02-2016, 11:08 PM
|
#18
|
Member
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702
|
Quote:
Originally Posted by Mikech
I wonder why you guys don't need "sudo" and I do?
|
Often the "sudo" is left off when posting because it is understood. But, also, I believe there are some distros that don't use "sudo" - you have to "su".
By the way, you should not run the command you have on a running system. You should do it from a live DVD or USB. There are system operations which do not need to be rsynced, and can cause problems.
If you want to do the rsync while logged on to the system, exclude the unnecessary processes.
Code:
rsync -avz --exclude={/proc,/dev,/media,/mnt,/sys,/tmp} . /path/to/save/to/ --delete --log-file=/path/to/report.rpt
|
|
1 members found this post helpful.
|
02-03-2016, 09:52 AM
|
#19
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep: 
|
Mike:
I offered
Code:
cd ~ && rsync -avz --dry-run . ...
because new users may take that snippet and try to run it from some place other than their home.
Of course I could have modified the rsync parameter...
|
|
1 members found this post helpful.
|
02-03-2016, 11:23 AM
|
#20
|
Member
Registered: Jan 2006
Location: USA
Distribution: Mint
Posts: 90
Original Poster
Rep:
|
Thanks to all who have helped me. I especially want to thank Habitual who spent a lot of time helping me understand things.
I have learned a great deal about Linux with this adventure. Using the command line that Habitual and TXLonghorn provided are the only things that worked. I now have 278.4 gigabytes on the Passport external hard drive and 278.4 on the source. While I had some errors, I don't care, because all the files I wanted are there so its working.
Not a single one of the 5 GUI front ends to rsync worked (including grsync). They either did nothing, refused to start, generated errors, or created a new directory inside /media/q and started a backup there instead of to the external hard drive (two of them did that!). I haven't got that many years left so I am not going to waste them trying to figure out why. The command line works good enough and I understand it well enough now to use it easily! Now I see why people use the CLI.
I will continue to study the rsync command though just so that I know what I am doing. Maybe then I can return the favor and help others.
Last edited by Mikech; 02-03-2016 at 11:28 AM.
|
|
|
02-03-2016, 12:03 PM
|
#21
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep: 
|
Glad it worked out for you.
|
|
|
02-03-2016, 10:43 PM
|
#22
|
Member
Registered: Jan 2015
Distribution: Slackware, LFS, OpenIndiana, debian wheezy
Posts: 55
Rep: 
|
nice work. I've been meaning to write one of these for awhile. you may prefer this for your cron job...
Code:
#!/bin/bash
##ultra simple backup program
##dependencies: bash rsync
###20160203 Polaris96 tested ok
##NOTES:
##
## 1. this script requires root priviledges
##
## 2. use any text editor (vi, nano, emacs, medit, kate, openoffice writer...)
## to examine the logfile
##
## 3. feel free to tweak anything
##
## 4. use at your own risk
##
#define your primary partition. this is what we're backing up
#the environment variable $HOME should already hold the path we need
PRIMARYDIR=$HOME
#define the backup partition. this is for the device node, not the mount
#if it's removable and you plan on detaching it, we'll need a udev rule.
#this assumes you'll leave it plugged in.
BACKUP_PARTITION=$/dev/<your passport partition>
#replace <your passport partition> with the actual designator
#if you aren't sure where it is run this from the command line
# cat /etc/mtab | awk '/MyPassport/{print $1}'
#you must have 'MyPassport' mounted when you run it. it will give the correct
#device Node.
#now tell bash where to mount the partition.
BACKUP_DIRECTORY=/media/q/MyPassport
#and create a logfile so you can track your backups
#change backups.log to a similar mnemonic title if you want.
BACKUP_LOGFILE=/var/log/backups.log
##with any luck, you won't need to change anything further
TimeStamp() {
echo $(date +"Y-%m-%d %H:%M:%S:")
}
#if the logfile doesn't exist create it
[ ! -e $BACKUP_LOGFILE ] && touch $BACKUP_LOGFILE
#see if the backup partition is mounted if not mount it
grep -qs $BACKUP_PARTITION /proc/mounts
[ $? -eq 1 ]&&{
mount $BACKUP_PARTITION $BACKUP_DIRECTORY
# make sure the mount works
[ $? -eq 0 ]&&{
echo "$(TimeStamp) mounted $BACKUP_PARTITION on $BACKUP_DIRECTORY." >> $BACKUP_LOGFILE
}||{
echo "$(TimeStamp) Failed to mount $BACKUP_PARTITION on $BACKUP_DIRECTORY." >> $BACKUP_LOGFILE
exit 1
}
}
#do the backup
#use any rsync recipe you want
#if you don't want compression, btw, you shouldn't be using the -z switch
#--delete is fine but i don't normally use it. This is how I back my servers
#using the -n switch will allow you to do test runs
rsync -av $PRIMARYDIR/ $BACKUP_DIRECTORY/
#log success or errors
[ $? -eq 0 ] && {
echo "$(TimeStamp) $PRIMARYDIR successfully backed up." >> $BACKUP_LOGFILE
} || {
echo "$(TimeStamp) Attempted $PRIMARYDIR backup. Errors detected." >> $BACKUP_LOGFILE
}
#uncomment the next line to unmount the backup partition
#umount $BACKUP_PARTITION
Last edited by polaris96; 02-03-2016 at 10:46 PM.
|
|
1 members found this post helpful.
|
02-04-2016, 11:25 PM
|
#23
|
Member
Registered: Jan 2006
Location: USA
Distribution: Mint
Posts: 90
Original Poster
Rep:
|
Words do not adequately express my gratitude polaris86! Thank you for writing the script.
I tried it and made the changes as indicated. Your directions were crystal clear and easy to follow.
However I get the following error:
Code:
mount: special device $/dev/sdd does not exist OR
mount: special device $/dev/sdd1 does not exist
Its the only line in the log file as well. I saved the file as "Backup" and changed the permissions to executable. I ran it with and without every combination of Bash and Sudo but got the same error every time. Seems to run even if I don't call Bash first.
I ran the rsync line by itself just as a test and it works great.
What I changed:
Code:
BACKUP_PARTITION=$/dev/sdd
Although the cat command returned "/dev/sdd1", I tried it both ways: as SDD and as SDD1 and got the same error. Gparted calls it both SDD and SDD1 depending on where in the dialog box it is displayed. Needless to say I don't think its very user friendly for Gparted to do that without an explanation! But it doesn't seem to matter which one I use. Upon reflection, though I think SDD1 is the one to go with.
I also tried unmounting (but left connected) the Passport hard drive but that just produced a "not found" error. The Passport drive is normally connected (and mounts automatically) unless I need the USB port to charge my IPad (which is rare since it is useless toy).
Also I do want to do the "delete" after Habitual explained what it does. Sometimes I reorganize the "q" user directory and I want that reflected in the backup. As you say I don't want any compressions and the last backup had the "z" in it. So its running in the background right now with the "delete" without any problems. I know its writing to the Passport because the drive is drawing .52 amps from the port where it only draws less than .2 amps when idle.
So I added "delete" to:
Code:
rsync -av $PRIMARYDIR/ $BACKUP_DIRECTORY/ --delete
The backup just finisheed with the usual error which I am guessing is not a big deal:
Code:
sent 174,930,015,812 bytes received 4,300,818 bytes 34,090,288.73 bytes/sec
total size is 278,347,138,411 speedup is 1.59
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]
I don't know if this matters or not but the USB3 port is a separate card that installed by cable to a USB3 header on the motherboard. The motherboard did not come with native USB3 ports in back, I have two of these ports and use them all the time. The operating system doesn't seem to have any problem with them.
Also when I bought the motherboard, UEFI was a new thing and setting it up on this board with SATA hard drives was a bit flaky. I only got it to work through trial and error. I should do a firmware update. Unfortunately doing motherboard updates with Linux is nontrivial! I could break its tenuous existence.
Last edited by Mikech; 02-04-2016 at 11:51 PM.
Reason: update info
|
|
|
02-05-2016, 08:24 AM
|
#24
|
Member
Registered: Jan 2015
Distribution: Slackware, LFS, OpenIndiana, debian wheezy
Posts: 55
Rep: 
|
OK, no worries! your backup problem came from this:
Code:
BACKUP_PARTITION=$/dev/sdd
can you see it? it took me a minute. Unfortunately, no matter how experienced a coder you are, little things WILL slip through. Remove the $
Code:
BACKUP_PARTITION=/dev/sdd1
should fix it. Btw the script was catching the error, which is what we need in things like cron jobs that often run at odd times. the string $/* isn't a proper path or a variable so bash didn't know what it was looking for.
You were smart to use the bundled cat | awk command. As mentioned in the comments, it didn't run well when the device was unmounted. The reason is that that code looks at a file called /etc/mtab. This file contains a list of all the currently mounted partitions, their mount points, their filesystem types, and their attributes. try and check it out. Very handy file, /etc/mtab. When you unmounted /dev/sdd1, the code couldn't find it in /etc/mtab because it wasn't there - the system erased it when you unmounted the partition. you'd need to look in in /dev, /proc/partitions, or (best) use the blkid command to find an unmounted but physically attached partition.
Remember, we need to tell the system which $PARTITION to mount. Specifying /dev/sdd indicates a whole device. In our case, it isn't specific enough.
your rsync syntax is also wrong.
Code:
rsync -av $PRIMARYDIR/ $BACKUP_DIRECTORY/ --delete
needs to be changed to
Code:
rsync -av --delete $PRIMARYDIR/ $BACKUP_DIRECTORY/
This may (or may not) fix the errors. Rsync's reference a prior run. It might be wise to wipe the destination media (rm -r *) before re-running the script.
None of the hardware issues you mention should be very relevant. One thing I WOULD do, though, is erase /dev/sdd1 and then delete the partition. Recreate and reformat the parition with a brand new FS and then re-run the script with a fully clean drive.
In fact, FIRST I'd fix the path for your backup as mentioned above. Then I'd run it and (hopefully) get a solid hit. THEN I'd erase, reformat and start with a fresh partition.
Finally, feel GOOD about all of this. You have no idea how much you're actually learning through all of this. This kind of thing seems monster only until you start "speaking the language". Pretty soon this all going to make sense
EDIT: And now I must say, "My Bad" I tested the script with different paths (mine) and, after it flew under test, I plugged your paths in. It was me that plugged in the unnecessary $. Sorry about that. Everything I wrote above is right, but you didn't make the error. I did.
Last edited by polaris96; 02-05-2016 at 08:40 AM.
|
|
1 members found this post helpful.
|
02-05-2016, 03:38 PM
|
#25
|
Member
Registered: Jan 2006
Location: USA
Distribution: Mint
Posts: 90
Original Poster
Rep:
|
That's great advice! I will wipe the drive and start over. Only thing is, and I don't think it matters, I have to format it as NTFS on a windows machine (its NTFS now). The reason is that I want to access my Linux files on the Windows machine. If I let Linux format the drive, Windows wants to "fix" it and someday I am going to accidentally hit the wrong button and Microsoft is gonna "fix" me good!
I did notice the dollar sign but I thought that was a LINUX thing. In windows the $ sign is used as an environmental variable prompt so I assumed it was some sort of requirement in Linux.
I only ran the cat command with the drive mounted. So the /dev/sdd1 was the mounted response.
Thanks for the correction on command line change. The manual showed the source and destination coming first and the options following. But I have never ever gotten any command to work following the "MAN." Most of it is unfathomable (may as well be written in Chinese)` and you have to know some sort of secret coding and formatting convention. When I see examples, their formatting looks nothing like what I see in the "MAN" other than the letter options are the same.
If you want to see errors you should come and watch me code in C and python. I have never written two lines of code that did not have formatting and syntax errors!! A programmer that worked for me a few years ago could write Visual Basic code at the speed of a touch typist and the code ran the first time every time. (Data Wizards in New Mexico in case anyone wants to hire him) Needless to say I was in awe!! He had a Ph.D. in economics from Berkeley and he was worth every penny of the 90 dollars an hour we paid him.
I have tested it again after the changes and it worked great! Its still running so I don't know if I will get errors but It doesn't matter I think I know what is causing that and I will fix it by removing those application files.
Last edited by Mikech; 02-05-2016 at 08:33 PM.
Reason: Update
|
|
|
02-06-2016, 07:45 AM
|
#26
|
Member
Registered: Jan 2015
Distribution: Slackware, LFS, OpenIndiana, debian wheezy
Posts: 55
Rep: 
|
Excellent.
LetMeTellYa, $NOBODY's code runs on the first try. What you weren't seeing from your former coworker was the hundreds of $GODAMMITs he went through prior to his fingers learning the script.
KEEP READING THE MANPAGES. The tumbler WILL drop and you'll start seeing it. In your defense, rsync is no manpage for the squeamish. I usually print it ( ~$man rsync > rsync.man Then open it in OO and reformat it before printing ) because I find there's too much info for reading on the screen. You can't beat paper for flipping back and forth.
Post if anything goes boink or you need more help.
|
|
|
02-06-2016, 07:52 AM
|
#27
|
Member
Registered: Jan 2015
Distribution: Slackware, LFS, OpenIndiana, debian wheezy
Posts: 55
Rep: 
|
Oh, btw, i was looking up some sparse backup script I wrote a while ago and came across -z switch. Turns out it compresses the data for TRANSMISSION across a network. It won't compress the files at the destination, but you still don't need it. It conserves bandwidth on Networks but you're doing an internal backup, so it would be superfluous.
|
|
1 members found this post helpful.
|
02-06-2016, 12:50 PM
|
#28
|
Member
Registered: Jan 2006
Location: USA
Distribution: Mint
Posts: 90
Original Poster
Rep:
|
Thanks Polaris96.
I was wrong about the manpages. It says to do it exactly the way you did it. I must have seen the information somewhere else and don't remember where. This has been happening a lot. I may be ready for the nursing home.
By the the way, Rick Berg of Data Wizards, the guy I was talking about, would come to my office and add features to the database right there at my desk with me looking over his shoulder. I was not exaggerating. He literally wrote the code as fast as anyone can type and the code ran without errors immediately. I hear what you are saying though, I have never met anyone else who could do that. He is some kind of genius. I would tell him what I needed and he would think for like 2 minutes and then write the code. Amazing!
Thanks again for taking the time to help me! I cannot thank you enough. I reformatted the drive (it took 18 hours on USB3)and I am running your code again. I like the way you wrote it. I only have to change the drive label in one place. If you ever come to New Mexico let me know, I will take you out to dinner (if I am still alive).
|
|
|
All times are GMT -5. The time now is 04:39 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|