Skip to content

Instantly share code, notes, and snippets.

@czj
Created May 13, 2019 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czj/c7c6b39eaca531a2554d0962d1f58515 to your computer and use it in GitHub Desktop.
Save czj/c7c6b39eaca531a2554d0962d1f58515 to your computer and use it in GitHub Desktop.
Download a Rails application's production attachements to your local machine
#!/usr/bin/env bash
APP_HOME=$( cd ${0%/*} && pwd -P )"/.."
REMOTE_SHARED="railsapp@host.domain.net:~/www/railsapp/shared"
SPEED_LIMIT=""
# Un-comment this line if you want to limit the download speed to un-clog your connexion
# SPEED_LIMIT="--bwlimit=500"
# -l forces copy of symlinks
#
# Other filters in exclude_assets to avoid getting large images
# **.[pP][dD][fF]
# **original**
# Make sure you are using a recent rsync version (3+) for the progress2 info
ARGS="--delete -lPrt --safe-links --exclude-from=$APP_HOME/script/exclude_assets --human-readable --progress --info=progress2 $SPEED_LIMIT"
rsync $ARGS $REMOTE_SHARED/public/attachments/ $APP_HOME/public/attachments/
rsync $ARGS $REMOTE_SHARED/private/ $APP_HOME/private/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment