In a bash script, I have:
I'm trying to move one file using:
mv $TEMPPATH/file $BACKUPPATH/file
I want to move the file from
/backup/path/file, but instead it ends up in
/backup/path/tmp/directory/file. I've tried adding and removing trailing slashes from the destination, and excluding the filename from the destination (just using the destination directory). I've searched and find a lot of methods for moving lots of files in a directory, but I only want to move one.
EDIT: here is the script section that causes the problem. It's part of a script that backs up WordPress folders and databases. Note: if you are wondering why I'm not just zipping the files directly to the backup location, it's because I'm writing to Keybase. If you haven't used Keybase, since i/o to and from it is so slow, my goal was to zip files locally then move the file after zipping is complete.
#back up the WordPress folder and move over to backup location echo Compressing site files zip -r --quiet $TEMPPATH/$DATEFORM-$SITE.wp-content.zip . echo Moving site zip file to Keybase #mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE/$DATEFORM-$SITE.wp-content.zip # ---------> this mv command works as expected: mv $TEMPPATH/$DATEFORM-$SITE.wp-content.zip $BACKUPPATH/$SITE #back up the WordPress database, compress, move to backup location and clean up echo Exporting database /usr/local/bin/wp db export $TEMPPATH/$DATEFORM-$SITE.sql --all-tablespaces --single-transaction --quick --lock-tables=false --allow-root --skip-themes --skip-plugins echo Compressing database zip --quiet $TEMPPATH/$DATEFORM-$SITE.sql.zip $TEMPPATH/$DATEFORM-$SITE.sql # ---------> this is the way the script was originally written -- maybe this cat method was used to prevent the same problem I am having? # cat $TEMPPATH/$DATEFORM-$SITE.sql | zip > $TEMPPATH/$DATEFORM-$SITE.sql.zip echo Moving sql zip file to Keybase # ---------> this is the mv command that results in the directory tree being copied over to the destination mv $TEMPPATH/$DATEFORM-$SITE.sql.zip $BACKUPPATH/$SITE echo Removing tmp file rm $TEMPPATH/$DATEFORM-$SITE.sql