LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2023, 07:31 AM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
[bash script] rsync won't create directory on usb mount


my backup script, I added a usb to it but it fails to created directory. I changed the ssd to 775 and still nope.

it works fine on going to my other drive on my laptop though. creates directories without error.


Code:
+ rsync -av --info=progress --exclude=lost+found --exclude=.cache --exclude=snap --exclude=.dbus /home/userx1 /run/media/userx/backup/HomeBackUps/Ubuntu/
sending incremental file list
rsync: [Receiver] mkdir "/run/media/userx/backup/HomeBackUps/Ubuntu" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(791) [Receiver=3.2.7]
+ echo /run/media/userx/backup/HomeBackUps/Ubuntu/userx1
/run/media/userx/backup/HomeBackUps/Ubuntu/userx1
the script

Code:
#!/usr/bin/env bash

set -x 
ck_for_OS()
{
if [[ -f /etc/slackware-version ]] ; then
	distroname=$(sed 's/Slackware /Slackware-/' /etc/slackware-version)
elif [[ "FreeBSD" =~ "$( awk 'NR==1{print $1}' /etc/*release | cut -d = -f2 | xargs)" ]] ; then
	distroname="$(uname -a | awk '{print $1 "-" $3}')"
	$HOME/bin/fbsd/mountdrives
else
	distroname=$( awk 'NR==1{print $1}' /etc/*release | cut -d = -f2 | xargs)
fi
sorce="$HOME"
dest="/media/storage/HomeBackUps/$distroname/"
if [[ -d /media/storage ]] ; then 
	mkdir -pv "$dest"
else
	echo "directory /media/storage not present .. exiting..."
	exit
fi

if [[ -f /etc/secondinstall ]] ; then
	dest="/media/storage/HomeBackUps/2nd-install-$distroname"
	sudo mkdir -p "$dest"
fi
}
go_4_distro()
{
if [[ "$distroname"  =~ "FreeBSD" ]] ; then
	sudo rsync -av --files-from=$HOME/bin/fbsd/fbsd-backup-list / $dest
	sudo chown -R $USER:$USER "$dest"
elif [[ "$distroname" =~ "Ubuntu" ]] ; then
	sudo rsync -av --files-from=$HOME/bin/linux-backup-list / $dest
	sudo chown -R $USER:$USER "$dest"
elif [[ "$distroname" =~ "Slackware" ]] ; then
	sudo rsync -av --files-from=$HOME/bin/linux-backup-list / $dest
	sudo chown -R $USER:users "$dest"	
fi
}
sync_me()
{
rsync -av --info=progress --exclude="lost+found" --exclude=".cache" --exclude="snap" --exclude=".dbus" "$sorce" "$dest" 
echo "$dest$USER"
}

ck_for_OS
go_4_distro
sync_me

 if mount | grep -q 'on /run/media/userx' &&  
[[ -f /run/media/$USER/backup/bkup ]] || 
[[ -f /media/$USER/backup/bkup ]] ; then
dest="/run/media/userx/backup/HomeBackUps/$distroname/"
go_4_distro
sync_me
else
echo "No usb inserted..."
exit 
fi
 
Old 06-08-2023, 08:02 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Original Poster
Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
okay it was not making directory yesterday and when I added Ubuntu today it was doing the same thing, only I didn't work out my if statements on this today so I did not look at the error that close until I posted it now that works
Code:
c_me

 if mount | grep -q 'on /run/media/userx' &&  
	[[ -f /run/media/$USER/backup/bkup ]] ; then
		dest="/run/media/userx/backup/HomeBackUps/$distroname/"
		go_4_distro
		sync_me

	elif   mount | grep -q 'on /media/userx1' &&  
	[[ -f /media/$USER/backup/bkup ]] ; then
		dest="/media/userx1/backup/HomeBackUps/$distroname/"
		go_4_distro
		sync_me
	
	else
		echo "No usb inserted..."
		exit 
fi
 
  


Reply



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
[SOLVED] Cygwin rsync related question - cygdrives invisible to rsync inside Cygwin bash script rylan76 Linux - Software 1 07-13-2022 04:12 AM
[SOLVED] Is it possible to create a bash script to create multiple new bash scripts Batistuta_g_2000 Linux - Newbie 6 02-19-2013 11:42 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 07:01 PM
webtree.bash - a script to create entire directory links in HTML mohan34u Programming 1 07-15-2007 08:07 AM
Mount. Umount. Mount. Umount. Mount. Umount. Mount.. cwizardone Slackware 10 03-22-2007 09:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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