LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 09-14-2020, 07:29 PM   #1
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Rep: Reputation: Disabled
rsync backup - job executed, but files not copied


I am working with KDE / Plasma 5

Here is my job description for the daily backup

Code:
#!/bin/bash 

#get day of week 
dow=$(/usr/bin/date "+%a") 

# convert DOW to lower case i.e. Mon to mon 
ldow=${dow,,} 

/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log
the rsync.log shows this morning the following single line

Code:
sending incremental file list
The syslog file shows as if all went OK, but when I check th eindividual files that I know were changed, I discover that they were not copied, here are some examples:

Code:
File type		Source				Destination

.xksx spreadsheet	22.3Kib  -  14/09/20		22.4KiB – 8/09/20
.docx Document		168.1KiB – 13/09/20		148.8KiB  - 8/09/20
There is a visible change in file size and file datte stamp, why wre the files not copied?

Thanks
Alex

Last edited by alex4buba; 09-14-2020 at 07:31 PM.
 
Old 09-15-2020, 08:10 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,627

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Try replacing your ">>" with "&>" so that both stdout AND stderr are redirected to the log file.
This way if it errors out before a file is synced, there will be evidence.

OR, you could redirect the error output to a "rsync.err" file. This would preserve the trace, but keep your log file clean.

Have you tested this script form the command line? ie, a manual run rather than scheduled.
 
Old 09-15-2020, 08:27 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
probably this helps: http://www.staroceans.org/e-book/und...e-changes.html
 
Old 09-15-2020, 03:44 PM   #4
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
Try replacing your ">>" with "&>" so that both stdout AND stderr are redirected to the log file.
This way if it errors out before a file is synced, there will be evidence.

OR, you could redirect the error output to a "rsync.err" file. This would preserve the trace, but keep your log file clean.

Have you tested this script form the command line? ie, a manual run rather than scheduled.
Sorry, I am still new to all this, you mean - instead of this line

Code:
/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log
What should it look like? Only ONE option please

Thanks
Alex
 
Old 09-15-2020, 04:58 PM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
as user from the CLI/Terminal type the following commands and paste the outputs here.

1. df -Th
2. ls -laF /media/alex/Elements
3. touch /media/alex/Elements/mon/foo.txt
 
Old 09-15-2020, 05:45 PM   #6
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546
Quote:
Originally Posted by alex4buba View Post
Sorry, I am still new to all this, you mean - instead of this line

Code:
/usr/bin/rsync -av /home/alex/afolders/ /media/alex/Elements/$ldow/ >> /tmp/rsync.log
What should it look like? Only ONE option please
Commands have two places where output can go - "standard output" (stdout) and "standard error" (stderr) - the latter is usually used for error messages, which are helpful when things are not working as expected.

The ">>" in your command appends the stdout of rsync to the file specified, but discards the stderr.

To append both stdout and stderr to your log file, use "&>>" instead of ">>".

(The process of sending stdout/stderr to a file is called redirection - more details on all the options are contained in the Redirections page of the manual. Reading manual pages is a great way to develop and reinforce understanding - even if it doesn't currently make sense, it will help things to click faster.)

 
1 members found this post helpful.
Old 09-15-2020, 06:07 PM   #7
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lleb View Post
as user from the CLI/Terminal type the following commands and paste the outputs here.

1. df -Th
2. ls -laF /media/alex/Elements
3. touch /media/alex/Elements/mon/foo.txt
I did what you instructed, below is the output of the 2 actions. The 3rd one - foo.txt was created but is empty.
I wish I could understand what are the results of those commands, hope you can help me understand

Thanks again
Alex

Code:
lex@alex-NUC8i7HNK:~$ df -Th 
Filesystem ***************Type *****Size *Used Avail Use% Mounted on 
udev *********************devtmpfs *7.8G ****0 *7.8G **0% /dev 
tmpfs ********************tmpfs ****1.6G *2.1M *1.6G **1% /run 
/dev/mapper/vgubuntu-root ext4 *****457G **76G *358G *18% / 
tmpfs ********************tmpfs ****7.8G **14M *7.8G **1% /dev/shm 
tmpfs ********************tmpfs ****5.0M *4.0K *5.0M **1% /run/lock 
tmpfs ********************tmpfs ****7.8G ****0 *7.8G **0% /sys/fs/cgroup 
/dev/loop1 ***************squashfs **55M **55M ****0 100% /snap/core18/1705 
/dev/loop2 ***************squashfs **56M **56M ****0 100% /snap/core18/1885 
/dev/loop3 ***************squashfs *241M *241M ****0 100% /snap/gnome-3-34-1804/24 
/dev/loop5 ***************squashfs *256M *256M ****0 100% /snap/gnome-3-34-1804/36 
/dev/loop4 ***************squashfs **97M **97M ****0 100% /snap/core/9804 
/dev/loop6 ***************squashfs **63M **63M ****0 100% /snap/gtk-common-themes/1506 
/dev/loop7 ***************squashfs **50M **50M ****0 100% /snap/snap-store/433 
/dev/loop0 ***************squashfs *9.2M *9.2M ****0 100% /snap/canonical-livepatch/95 
/dev/loop8 ***************squashfs **83M **83M ****0 100% /snap/scrcpy/254 
/dev/loop9 ***************squashfs **31M **31M ****0 100% /snap/snapd/9279 
/dev/loop10 **************squashfs **50M **50M ****0 100% /snap/snap-store/467 
/dev/loop11 **************squashfs **20M **20M ****0 100% /snap/video-downloader/576 
/dev/loop12 **************squashfs **30M **30M ****0 100% /snap/snapd/8790 
/dev/loop13 **************squashfs **20M **20M ****0 100% /snap/video-downloader/580 
/dev/sda1 ****************vfat *****511M *7.8M *504M **2% /boot/efi 
tmpfs ********************tmpfs ****1.6G **24K *1.6G **1% /run/user/1000 
/dev/sdb1 ****************fuseblk **2.8T *1.3T *1.6T *45% /media/alex/Elements 
/dev/sde1 ****************exfat ****477G **82G *396G *18% /media/alex/New-SD-512 
alex@alex-NUC8i7HNK:~$ 


alex@alex-NUC8i7HNK:~$ ls -laF /media/alex/Elements 
total 120 
drwxrwxrwx *1 alex alex *8192 Sep 13 16:48 *./ 
drwxr-x---+ 4 root root *4096 Sep 16 06:37 *../ 
drwxrwxrwx *1 alex alex ****0 Aug 28 00:11 '$RECYCLE.BIN'/ 
drwxrwxrwx *1 alex alex *4096 Sep 12 18:50 *A-DT_Ubuntu/ 
drwxrwxrwx *1 alex alex 45056 Aug 24 16:53 *A-FS_Backup/ 
drwxrwxrwx *1 alex alex *4096 Sep *7 16:24 *alexfolders/ 
drwxrwxrwx *1 alex alex *8192 Sep *7 22:23 *DirSync/ 
drwxrwxrwx *1 alex alex *4096 Sep *8 07:07 *fri/ 
drwxrwxrwx *1 alex alex *4096 Sep 15 08:46 *mon/ 
drwxrwxrwx *1 alex alex ****0 Aug 24 17:02 *Old-Things/ 
drwxrwxrwx *1 alex alex *4096 Sep *9 13:12 *OurVilla/ 
drwxrwxrwx *1 alex alex ****0 Sep 12 17:23 *sat/ 
drwxrwxrwx *1 alex alex *4096 Sep 13 06:47 *sun/ 
drwxrwxrwx *1 alex alex *4096 Aug 24 06:02 'System Volume Information'/ 
drwxrwxrwx *1 alex alex *4096 Sep 10 10:00 *Targz_Files/ 
drwxrwxrwx *1 alex alex *8192 Sep *9 16:54 *thu/ 
drwxrwxrwx *1 alex alex ****0 Aug 30 11:56 *.Trash-1000/ 
drwxrwxrwx *1 alex alex *8192 Sep 16 06:38 *tue/ 
drwxrwxrwx *1 alex alex *4096 Sep *7 16:21 *W-Desktop/ 
drwxrwxrwx *1 alex alex *4096 Sep 16 08:56 *wed/ 
drwxrwxrwx *1 alex alex ****0 Jun *4 09:36 *WindowsImageBackup/ 
alex@alex-NUC8i7HNK:~$
 
Old 09-15-2020, 06:12 PM   #8
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by boughtonp View Post
Commands have two places where output can go - "standard output" (stdout) and "standard error" (stderr) - the latter is usually used for error messages, which are helpful when things are not working as expected.

The ">>" in your command appends the stdout of rsync to the file specified, but discards the stderr.

To append both stdout and stderr to your log file, use "&>>" instead of ">>".

(The process of sending stdout/stderr to a file is called redirection - more details on all the options are contained in the Redirections page of the manual. Reading manual pages is a great way to develop and reinforce understanding - even if it doesn't currently make sense, it will help things to click faster.)
Sounds like a good idea, I will change the script before the next run.

Yes, I have a long way to go, thanks for pointing me to the manual.

Where can I see the std.err file?

Cheers
Alex
 
Old 09-16-2020, 07:00 AM   #9
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546
Quote:
Originally Posted by alex4buba View Post
Where can I see the std.err file?
Huh? Nobody mentioned a "std.err file"

The third line of my previous post describes how to append rsync's stderr into your existing "/tmp/rsync.log" file, which will be in the "/tmp" directory, (and can, if desired, be sent to another directory by changing the path appropriately).

 
Old 09-16-2020, 09:26 AM   #10
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Ok all of that looks good, what happened when you performed #3, the touch command? Any errors?

Here is my backup code, feel free to modify as you see fit:

Code:
#!/bin/bash
#
###########################################################
# Created by ME January 11, 2015
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or version 3 of the
# license, at your option.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#############################################################
#
#
#############################################################
#
#	Backup program for laptops to Linux server using 
#	rsync -aviS
#
#############################################################

#	Veriables

RUSER=user
RHOST=xxx.xxx.xxx.xxx
WHO=`whoami`
DOW=`date +%A`
RDIR=/exports/backup
HOMEDIR="$HOME"
dtstamp="`date +%Y-%m-%d-%H:%M `"
log=${HOMEDIR}/logs/${dtstamp}-rsync.log

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

### 	Check for a logs directory, if not found create one
###############################################################

[ ! -d "${HOMEDIR}/logs" ] && mkdir -p ${HOMEDIR}/logs >> /dev/null 2>&1

###############################################################
#
#	Rsync preserving permissions
#
###############################################################

	rsync -aviS --exclude-from=${HOMEDIR}/excludes.txt ${HOMEDIR}/ ${RUSER}@${RHOST}:${RDIR}/${WHO}/${DOW}/ >> ${log} 2>&1

### 	Cleaning up log files
###############################

	find ${HOMEDIR}/logs/*.log -mtime +30 -exec rm '{}' \;

exit
Quote:
Originally Posted by alex4buba View Post
I did what you instructed, below is the output of the 2 actions. The 3rd one - foo.txt was created but is empty.
I wish I could understand what are the results of those commands, hope you can help me understand

Thanks again
Alex

Code:
lex@alex-NUC8i7HNK:~$ df -Th 
Filesystem ***************Type *****Size *Used Avail Use% Mounted on 
udev *********************devtmpfs *7.8G ****0 *7.8G **0% /dev 
tmpfs ********************tmpfs ****1.6G *2.1M *1.6G **1% /run 
/dev/mapper/vgubuntu-root ext4 *****457G **76G *358G *18% / 
tmpfs ********************tmpfs ****7.8G **14M *7.8G **1% /dev/shm 
tmpfs ********************tmpfs ****5.0M *4.0K *5.0M **1% /run/lock 
tmpfs ********************tmpfs ****7.8G ****0 *7.8G **0% /sys/fs/cgroup 
/dev/loop1 ***************squashfs **55M **55M ****0 100% /snap/core18/1705 
/dev/loop2 ***************squashfs **56M **56M ****0 100% /snap/core18/1885 
/dev/loop3 ***************squashfs *241M *241M ****0 100% /snap/gnome-3-34-1804/24 
/dev/loop5 ***************squashfs *256M *256M ****0 100% /snap/gnome-3-34-1804/36 
/dev/loop4 ***************squashfs **97M **97M ****0 100% /snap/core/9804 
/dev/loop6 ***************squashfs **63M **63M ****0 100% /snap/gtk-common-themes/1506 
/dev/loop7 ***************squashfs **50M **50M ****0 100% /snap/snap-store/433 
/dev/loop0 ***************squashfs *9.2M *9.2M ****0 100% /snap/canonical-livepatch/95 
/dev/loop8 ***************squashfs **83M **83M ****0 100% /snap/scrcpy/254 
/dev/loop9 ***************squashfs **31M **31M ****0 100% /snap/snapd/9279 
/dev/loop10 **************squashfs **50M **50M ****0 100% /snap/snap-store/467 
/dev/loop11 **************squashfs **20M **20M ****0 100% /snap/video-downloader/576 
/dev/loop12 **************squashfs **30M **30M ****0 100% /snap/snapd/8790 
/dev/loop13 **************squashfs **20M **20M ****0 100% /snap/video-downloader/580 
/dev/sda1 ****************vfat *****511M *7.8M *504M **2% /boot/efi 
tmpfs ********************tmpfs ****1.6G **24K *1.6G **1% /run/user/1000 
/dev/sdb1 ****************fuseblk **2.8T *1.3T *1.6T *45% /media/alex/Elements 
/dev/sde1 ****************exfat ****477G **82G *396G *18% /media/alex/New-SD-512 
alex@alex-NUC8i7HNK:~$ 


alex@alex-NUC8i7HNK:~$ ls -laF /media/alex/Elements 
total 120 
drwxrwxrwx *1 alex alex *8192 Sep 13 16:48 *./ 
drwxr-x---+ 4 root root *4096 Sep 16 06:37 *../ 
drwxrwxrwx *1 alex alex ****0 Aug 28 00:11 '$RECYCLE.BIN'/ 
drwxrwxrwx *1 alex alex *4096 Sep 12 18:50 *A-DT_Ubuntu/ 
drwxrwxrwx *1 alex alex 45056 Aug 24 16:53 *A-FS_Backup/ 
drwxrwxrwx *1 alex alex *4096 Sep *7 16:24 *alexfolders/ 
drwxrwxrwx *1 alex alex *8192 Sep *7 22:23 *DirSync/ 
drwxrwxrwx *1 alex alex *4096 Sep *8 07:07 *fri/ 
drwxrwxrwx *1 alex alex *4096 Sep 15 08:46 *mon/ 
drwxrwxrwx *1 alex alex ****0 Aug 24 17:02 *Old-Things/ 
drwxrwxrwx *1 alex alex *4096 Sep *9 13:12 *OurVilla/ 
drwxrwxrwx *1 alex alex ****0 Sep 12 17:23 *sat/ 
drwxrwxrwx *1 alex alex *4096 Sep 13 06:47 *sun/ 
drwxrwxrwx *1 alex alex *4096 Aug 24 06:02 'System Volume Information'/ 
drwxrwxrwx *1 alex alex *4096 Sep 10 10:00 *Targz_Files/ 
drwxrwxrwx *1 alex alex *8192 Sep *9 16:54 *thu/ 
drwxrwxrwx *1 alex alex ****0 Aug 30 11:56 *.Trash-1000/ 
drwxrwxrwx *1 alex alex *8192 Sep 16 06:38 *tue/ 
drwxrwxrwx *1 alex alex *4096 Sep *7 16:21 *W-Desktop/ 
drwxrwxrwx *1 alex alex *4096 Sep 16 08:56 *wed/ 
drwxrwxrwx *1 alex alex ****0 Jun *4 09:36 *WindowsImageBackup/ 
alex@alex-NUC8i7HNK:~$
 
Old 09-16-2020, 09:28 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
command >file1 2>file2
you specify [the name of] file1 and file2 and they will contain the stdout and stderr output of the command. command is the full command line (without >, >> or similar).
 
1 members found this post helpful.
Old 09-16-2020, 03:37 PM   #12
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
command >file1 2>file2
you specify [the name of] file1 and file2 and they will contain the stdout and stderr output of the command. command is the full command line (without >, >> or similar).
Sory, I am new here, not clear on your instructions

A full example, based on my current code will really help

Thnaks
Alex
 
Old 09-16-2020, 03:41 PM   #13
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by pan64 View Post
command >file1 2>file2
you specify [the name of] file1 and file2 and they will contain the stdout and stderr output of the command. command is the full command line (without >, >> or similar).
Quote:
Originally Posted by alex4buba View Post
Sory, I am new here, not clear on your instructions

A full example, based on my current code will really help
Emphasis added.
I don't see how that could be any clearer...you have to do some working at learning.
 
Old 09-16-2020, 04:01 PM   #14
alex4buba
Member
 
Registered: Jul 2020
Posts: 620

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
Emphasis added.
I don't see how that could be any clearer...you have to do some working at learning.
OK, Let me ask you somethings (no need to answer)

1) How long have you been using Linux? Me, just over 2 months
2) How old are you? I am 75

If someone is asking again, it means that they didn't get it - so, there are two options:

1) You "Smile" in your mind and this they are funny, OR
2) You understand that your initial hint was not enough, and if you have time - you give them a full example

I know, it is very hard for veterans, to get down into the minds of newbies...

Have a nice day
Alex
 
Old 09-16-2020, 04:21 PM   #15
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
It's not about being a newbie, it's about you making some effort to understand what you're being told.
We shouldn't have to spoon feed you.
command means your rsync command
>file1 means the file to capture the stdout
2>file2 means the file to capture the stderr

I don't see how that could be put any clearer, unless we simply type your commands for you. You'll learn better if you figure it out yourself.

Remember that the /full/path/to/file1 (the "absolute path") needs to be specified because you're working on a cron job.

We are of a similar age. Yes, I have been programming computers for a very long time (> 40 years), but I've always avoided calling myself an "expert," even when I was the resident expert.

The way to learn how to use Linux (or anything) is to learn how to look up how.
On Linux, that's the man pages, which are available online if you aren't comfortable reading them in a terminal. Simply put man command into your favorite search engine and you'll get several links to online copies of the documentation.

You need to answer the specific questions you've been asked. Show us the ls -l of the source and destination files that you think should be the same but aren't.

You should be getting a summary, either in the log files you're creating or in the emails being sent to root.
 
  


Reply

Tags
anacron, backup, rsync



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
copied files from SOURCE to TARGET but now want to rsync SOURCE to existing TARGET teddymills1 Linux - Newbie 3 10-28-2019 07:07 AM
rsync - not able to add suffix in copied files unclesamcrazy Linux - Newbie 3 06-22-2015 02:18 PM
ShellScript executed from command prmpt but not executed from crontab or at command BMMadhav Linux - Newbie 1 11-16-2012 07:20 PM
[SOLVED] Configured Cron job executed every hour is instead executed every minute for 10m markings Linux - Software 4 05-13-2012 05:43 PM
[SOLVED] Xwindow's program will not run when executed on boot or when executed remotely richman1234 Programming 2 10-08-2010 01:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:09 PM.

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