Reputation: 147
I have this line of code:
#!/bin/bash
USER="root"
PASS="sjkndkfjnweif"
SERVER="192.168.1.1"
SOURCE="/var/www/a1/"
TARGET="/volume1/a1/"
LOG="/volume1/homes/admin/backup-a1.log"
lftp sftp://$USER:$PASS@$SERVER -e 'mirror -r '$SOURCE $TARGET'; bye'
Script is called execute.sh and is located in this folder:
/volume1/homes/admin/execute.sh
I need that variable target is backuping in this folder:
/volume1/a1
And my script screates subdirectory in witch this script is run for example:
/volume1/homes/admin/a1/
I need to create folder for backup in
/volume1/a1
I try to add
./volume1/a1/ and ~/volume1/a1 but it every time script is run it creates subdirectory in folder that script it is run.
How to fix this to be working as it should be?
Upvotes: 1
Views: 1863
Reputation: 3801
mirror [OPTS] [source [target]]
Mirror specified source directory to local target directory. If the target directory ends with a slash (except the root), the source base name is appended to target directory name. Source and/or target can be URLs pointing to directories.
So remove slash from TARGET
first:
TARGET="/volume1/a1"
Then you have to specify target base directory: --target-directory
--target-directory=DIR
Your final command line:
lftp sftp://$USER:$PASS@$SERVER -e "mirror -r --target-directory=/ $SOURCE $TARGET"
Upvotes: 1