Has you already found the variable needs to be FILEBACKUPLOCATION=/location
with no space, also if possible try to make your script a little more portable by using something like:
FILEBACKUPLOCATION=$HOME/backup/FMonday
In this case, the location is relative to your user $HOME
environment variable.
Going further, if you want to keep 2 files in sync probably you could do better with rsync
one of the advantages is that it will only copy the files that don't exist or update the ones that have been changed.
You indeed could create an alias to copy/sync files on demand, for example:
alias cpr="rsync --delete --archive --numeric-ids --human-readable --no-compress --whole-file --verbose --info=progress2"
Then if you would like to sync contents of /dir/foo
into /dir/bar
, could simply do:
$ cpr /dir/foo/ /dir/bar/
Your script also could then be something like:
#!/bin/sh
ORIGIN=/path/to/foo/
DESTINATION=/path/to/bar/
rsync --delete \
--archive \
--numeric-ids \
--human-readable \
--no-compress \
--whole-file \
--verbose \
--info=progress2 \
$ORIGIN $DESTINATION
Notice that in this case the options --no-compress
and --whole-file
are used, mainly because the files will be copied locally, if this where a remote server options could be different, check this post (The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)
...
Note that...
has a special meaning in some contexts (Novel NetWare, Windows 95, Golang). --- Using double quotes around variable references will also better show that the variable is either empty or nonexistent and it will better handle possible errors in such cases (typical example which can overwrite files:cp path/* $nonexistent_var
). – Underwater