LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 08-22-2020, 03:53 PM   #46
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222

From man rsync
Quote:
rsync -avz foo:src/bar/ /data/tmp

A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo:
Using rsync requires a careful and repeated reading of the man page. I find --dry-run (-n) and --verbose (-v) to be particularly useful.
 
Old 08-22-2020, 04:00 PM   #47
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
From man rsync

Using rsync requires a careful and repeated reading of the man page. I find --dry-run (-n) and --verbose (-v) to be particularly useful.
I understand what the / is doing in the source section - if it is missing - it will create that folder in the destination, but you said earlier to create the target folder on the destination drive BEFORE executing the backup.

I was asking about the final / in the destination instruction. do I add the / after sun? or not

Please give me an example of a one line - complete based on my example, based on this one line - will I need to create the folder ahead or not?

What is the point of the -v / verbose argument? I am not sitting there to watch the backup? My Terminal window is NOT open either at backup time

Thanks again
Alex
 
Old 08-22-2020, 04:04 PM   #48
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by alex4buba View Post
I know that crontab -l is only showing me the list
Which user I am when I run crontab -e? How can I find out?
Cron log file? Attached a screen image of my /var/log/ folder - tere is no such file in it, can you suggest which one should I look in?

Yes, the command rsync -r runs ok

Thanks
Alex
When you run crontab -e, are you root or using sudo, or are you just your normal user?
I don't know where your system logs cron. See what man cron says about logs on your system.
 
Old 08-22-2020, 04:19 PM   #49
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by alex4buba View Post
I was asking about the final / in the destination instruction. do I add the / after sun? or not

Please give me an example of a one line - complete based on my example, based on this one line - will I need to create the folder ahead or not?

What is the point of the -v / verbose argument? I am not sitting there to watch the backup? My Terminal window is NOT open either at backup time
As I understand it, and as sgosnell has said a couple of times here, yes, the destination directory must exist prior to running rsync. rsnapshot manages that for me by creating the destination directory before running the rsync command.

DEST trailing slash: I'm not sure. I see that the command that rsnapshot created I posted in #36 has a trailing slash, but most of the examples in the man page do not. Try it both ways and see what happens.

-v is useful when doing dry runs to see what's going to be copied. I agree it's not necessary on cron runs.
 
Old 08-22-2020, 04:19 PM   #50
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
When you run crontab -e, are you root or using sudo, or are you just your normal user?
I don't know where your system logs cron. See what man cron says about logs on your system.
When I run crontab -e, I just type it as it is, am I supossed to type : sudo crontab -e ?
I understand you don't see what is in front of me.

I will check the manual

Thank you
Alex
 
Old 08-22-2020, 04:26 PM   #51
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by alex4buba View Post
When I run crontab -e, I just type it as it is, am I supossed to type : sudo crontab -e ?
Not necessarily. As long as the files you're copying are readable by the user that's running the job (you), you don't (shouldn't) need to be root. If running your rsync command from the command line creates your backup, then you should be ok.

It's not clear to me whether or not you've successfully created a backup yet. Take the problem is steps.
  1. set up your destination
  2. run the rsync manually, from the command line - confirm it worked
  3. set up the crontab - confirm that worked.
 
Old 08-22-2020, 05:12 PM   #52
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
Not necessarily. As long as the files you're copying are readable by the user that's running the job (you), you don't (shouldn't) need to be root. If running your rsync command from the command line creates your backup, then you should be ok.

It's not clear to me whether or not you've successfully created a backup yet. Take the problem is steps.
  1. set up your destination
  2. run the rsync manually, from the command line - confirm it worked
  3. set up the crontab - confirm that worked.
OK, Here is what I did

1) In the target device, i created manually a folder called sun (for Sunday)
2) In teminal mode, I executed : rsync -rv /home/alex/alexfolders /media/New-SD-512/sun
3) I got error - permission denied
4) Then I ran sudo rsync -rv /home/alex/alexfolders /media/New-SD-512/sun

The command is now running and doing it!

So, why does the cron job not doing it, how can I get the cron job to run as sudo / root automatically?

Thanks
Alex
 
Old 08-22-2020, 05:17 PM   #53
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Quote:
Originally Posted by alex4buba View Post
I am with you on not doing multiple things at the same time, I just pointed out another thought.
I thought, that the word weekly at the end tells cron to run it weekly, from what you say - it is not.

So, let me see - assume I have a blank target device - will I need in this case (after I drop the word weekly) create on that target drive 7 folders : sun,mon etc... in the root of the drive? Then the comman will look like this:

0 20 * * 0 rsync -a /home/alex/alexfolders /media/New-SD-512/sun - with or without the slash / at the end?

Thank you
Alex
No, weekly at the end does not run it weekly. That was just a hypothetical name of a folder on the destination. The times the command is run by cron is determined entirely by the first 5 positions in the line.
Yes, you will have to create all those folders on the destination drive. Then put a line in the crontab for each day, as shown above.
 
Old 08-22-2020, 05:22 PM   #54
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sgosnell View Post
No, weekly at the end does not run it weekly. That was just a hypothetical name of a folder on the destination. The times the command is run by cron is determined entirely by the first 5 positions in the line.
Yes, you will have to create all those folders on the destination drive. Then put a line in the crontab for each day, as shown above.
OK, I ran the one line for Sunday in Terminal mode ... It finished too fast IMO... At the end, i had this message


sent 36,998,650,777 bytes received 400,345 bytes 132,851,170.99 bytes/sec
total size is 36,988,192,756 speedup is 1.00

The sun folder was however empty

So, what can I do?
Alex
 
Old 08-22-2020, 05:23 PM   #55
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
The permissions problem is an ownership problem. Alex does not own /media/New-SD-512, root does. You have two options. Change the ownership, or run the cronjobs through the root crontab. I would probably change the ownership.
Code:
sudo chown -r alex:alex /media/New-SD-512
 
Old 08-22-2020, 05:29 PM   #56
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
I have no idea what, exactly, you did with "OK, I ran the one line for Sunday in Terminal mode " We need the exact syntax you used. Try this:
Code:
rsync -av /home/alex/alexfolders/ /media/New-SD-512/sun/
after changing ownership of the SD card, or precede that with sudo. The verbose option may give you some clues about errors, if they happen.
 
Old 08-22-2020, 06:03 PM   #57
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sgosnell View Post
I have no idea what, exactly, you did with "OK, I ran the one line for Sunday in Terminal mode " We need the exact syntax you used. Try this:
Code:
rsync -av /home/alex/alexfolders/ /media/New-SD-512/sun/
after changing ownership of the SD card, or precede that with sudo. The verbose option may give you some clues about errors, if they happen.
I ran the same command before , but without the / after sun.
Now I ran it again, following your example with the / at the end, I got this message

alex@alex-nuc8i7hnk:~$ sudo rsync -av /home/alex/alexfolders /media/New-SD-512/sun/
[sudo] password for alex:
sending incremental file list

sent 614,813 bytes received 3,507 bytes 1,236,640.00 bytes/sec
total size is 36,988,192,756 speedup is 59,820.47


BUT - the sun folder is still EMPTY

So,?
 
Old 08-22-2020, 06:04 PM   #58
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sgosnell View Post
I have no idea what, exactly, you did with "OK, I ran the one line for Sunday in Terminal mode " We need the exact syntax you used. Try this:
Code:
rsync -av /home/alex/alexfolders/ /media/New-SD-512/sun/
after changing ownership of the SD card, or precede that with sudo. The verbose option may give you some clues about errors, if they happen.
No idea how do I change ownership?
 
Old 08-22-2020, 06:06 PM   #59
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by alex4buba View Post
No idea how do I change ownership?
#55
Please use code tags when posting terminal output!!
 
Old 08-22-2020, 06:12 PM   #60
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by alex4buba View Post
I ran the same command before , but without the / after sun.
Now I ran it again, following your example with the / at the end, I got this message

Code:
alex@alex-nuc8i7hnk:~$ sudo rsync -av /home/alex/alexfolders /media/New-SD-512/sun/
[sudo] password for alex: 
sending incremental file list

sent 614,813 bytes  received 3,507 bytes  1,236,640.00 bytes/sec
total size is 36,988,192,756  speedup is 59,820.47
BUT - the sun folder is still EMPTY

So,?
Any clues in the verbose output?
With no trailing / on the source, there should be a alexfolders directory in the sun directory
Incremental?

Last edited by scasey; 08-22-2020 at 06:13 PM.
 
  


Reply

Tags
backup, restore



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
Newbie trying to write a simple backup script to backup a single folder Nd for school stryker759a Linux - Newbie 2 09-16-2009 08:52 AM
Permission problem with importing evolution mail from the old .evolution folder oskar Linux - Software 4 05-23-2008 08:28 PM
New installation: restoring the old home folder? Backup advices bruno321 Linux - General 4 11-18-2007 08:55 AM
weird error restoring Evolution melinda_sayang Linux - Software 4 11-08-2005 01:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:24 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