Last active
April 28, 2016 08:06
-
-
Save huglester/7335674 to your computer and use it in GitHub Desktop.
FTP mirror (PyroCMS example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run from: | |
# /var/www/vhosts/domain/ | |
COMMAND="$1" | |
if [[ -d ".lftp" && $COMMAND != "install" ]]; then | |
COMMAND="update" | |
else | |
COMMAND="install" | |
fi | |
HOST="" | |
USER="" | |
PASS="" | |
FTPURL="ftp://$USER:$PASS@$HOST" | |
LCD="/var/www/vhosts/exampledomain/public" | |
RCD="/domains/exampledomain.lt/public_html" | |
#DELETE="--delete" | |
PARALLEL="--parallel=3" | |
if [ $COMMAND == 'update' ]; then | |
echo "Updating project files..."; | |
lftp -c "set ftp:list-options -a; | |
open '$FTPURL'; | |
set cmd:fail-exit yes; | |
lcd $LCD; | |
set cmd:fail-exit yes; | |
cd $RCD; | |
mirror --reverse \ | |
$DELETE \ | |
$PARALLEL \ | |
--verbose \ | |
--exclude .gitignore \ | |
--exclude ^.env$ \ | |
--exclude .git/ \ | |
--exclude ^.idea/ \ | |
--exclude-glob storage/logs/*.php \ | |
--exclude-glob system/cms/logs/*.php \ | |
--exclude-glob system/cms/cache/default/*/* \ | |
--exclude-glob system/cms/cache/default/* \ | |
--exclude ^photobanks/ \ | |
--exclude ^.idea/ \ | |
--exclude ^uploads/" | |
else | |
echo "Installing project for the first time... "; | |
lftp -c "set ftp:list-options -a; | |
open '$FTPURL'; | |
set cmd:fail-exit yes; | |
lcd $LCD; | |
set cmd:fail-exit yes; | |
cd $RCD; | |
mirror --reverse \ | |
$DELETE \ | |
$PARALLEL \ | |
--verbose \ | |
--exclude .gitignore \ | |
--exclude ^.env$ \ | |
--exclude .git/ \ | |
--exclude ^.idea/ \ | |
--exclude-glob storage/logs/*.php \ | |
--exclude-glob system/cms/logs/*.php \ | |
--exclude-glob system/cms/cache/default/*/* \ | |
--exclude-glob system/cms/cache/default/*" | |
fi | |
echo "Done."; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://serverfault.com/questions/24622/how-to-use-rsync-over-ftp