Upload Your Files
Files refer to everything stored inside sites/default/files
. This usually consists of uploaded images, generated stylesheets, aggregated scripts, etc. Files are not under Git version control and are stored separately from the site's code.
You can use the Pantheon Dashboard, SFTP, or Rsync to upload your site's files.
Follow the steps below to export a tar.gz
or .zip
file of your directory files.
Export a
tar.gz
or.zip
file of your files directory:Navigate to your Drupal site's root directory to run this command, which will create an archive file in your user's home directory:
cd sites/default/files tar -czf ~/files.tar.gz .
Select the Dev environment in the Site Dashboard.
Select Database / Files.
Click Import and add your archive accordingly (based on file size):
If your archive is under 100MB, you can upload the file directly:
Click File in the MySQL database field > Choose File.
Select your local archive file and click Import.
Note: If you recently imported the database and need to re-import, refresh the page and use a new filename for the database file.
If your archive is less than 500MB, you can import it from URL:
Click URL in the Archive of site files field.
Paste a publicly accessible URL for the archive and click Import.
- Change the end of the Dropbox URLs from
dl=0
todl=1
to ensure that your archive imports correctly.
- Change the end of the Dropbox URLs from
Rsync is an excellent method for transferring a large number of files. After performing an initial rsync, subsequent jobs will only transfer the latest changes. This can help minimize the amount of time a site is in an unpredictable state (or offline) during the final step of a migration, as it allows you to bring over only new content, rather than re-copying every single file.
We recommend looking into the Terminus Rsync Plugin as a helper when doing these operations, as the number of command line arguments and specifics of directory structure make it easy for human error to impact your operation.
To sync your current directory to Pantheon, run the following command:
terminus rsync . my_site.dev:files
When using Rsync manually, the script below is useful for dealing with transfers that are interrupted due to connectivity issues. It uploads files to your Pantheon site's Dev environment. If an error occurs during transfer, it waits two minutes and picks up where it left off:
#!/bin/bash # manual-rsync-script.sh # runs Rsync and waits two minutes if it doesn't work ENV='dev' SITE='SITEID' read -sp "Your Pantheon Password: " PASSWORD if [[ -z "$PASSWORD" ]]; then echo "Whoops, need password" exit fi while [ 1 ] do sshpass -p "$PASSWORD" rsync --partial -rlvz --size-only --ipv4 --progress -e 'ssh -p 2222' ./files/* --temp-dir=../tmp/ $ENV$SITE@appserver.$ENV.$SITE.drush.in:files/ if [ "$?" = "0" ] ; then echo "rsync completed normally" exit else echo "Rsync failure. Backing off and retrying..." sleep 180 fi done