First, create a directory to store your backup for safety:
mkdir -p ~/trellis-backup
Step 2: Back up the entire current trellis directory including hidden files
Copy your entire existing Trellis setup to the backup location, preserving all permissions and hidden files:
cp -ra ~/code/website.com/trellis/ ~/trellis-backup/
Create a temporary directory and clone the latest version of Trellis from the official repository:
mkdir -p ~/trellis-temp
cd ~/trellis-temp
git clone [email protected]:roots/trellis.git
Compare the fresh clone with your existing setup to understand what changes would be made:
mkdir -p ~/trellis-diff
diff -rq ~/trellis-temp/trellis/ ~/code/website.com/trellis/ > ~/trellis-diff/changes.txt
Delete the Git repository information from the fresh clone to prevent conflicts during the update:
rm -rf ~/trellis-temp/trellis/.git
Copy all new files to your existing Trellis setup, while carefully excluding your custom configurations and sensitive files:
rsync -av \
--exclude=".vault_pass" \
--exclude=".trellis/" \
--exclude=".git/" \
--exclude=".github/" \
--exclude="group_vars/all/vault.yml" \
--exclude="group_vars/development/vault.yml" \
--exclude="group_vars/production/vault.yml" \
--exclude="group_vars/staging/vault.yml" \
--exclude="group_vars/development/wordpress_sites.yml" \
--exclude="group_vars/production/wordpress_sites.yml" \
--exclude="group_vars/staging/wordpress_sites.yml" \
--exclude="group_vars/all/users.yml" \
--exclude="trellis.cli.yml" \
--exclude="hosts/" \
~/trellis-temp/trellis/ ~/code/website.com/trellis/
Remove the temporary directory as it's no longer needed:
rm -rf ~/trellis-temp
Navigate back to your main project directory:
cd ~/code/website.com
Review what files have changed in your Git repository:
git status
Examine the specific changes made to your Trellis files:
git diff trellis/
Stage the updated files for committing:
git add trellis/
Save the changes with a descriptive commit message:
git commit -m "Update Trellis to latest version while preserving custom configurations"