Skip to content

Instantly share code, notes, and snippets.

@huglester
Last active April 28, 2016 08:06
Show Gist options
  • Save huglester/7335674 to your computer and use it in GitHub Desktop.
Save huglester/7335674 to your computer and use it in GitHub Desktop.
FTP mirror (PyroCMS example)
#!/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;
@huglester
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment