Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How exclude specific folders to update on the server with rsync pipeline

Marcos Almeida March 5, 2024

Hello,

I am using rsync pipeline to deploy to my server, but it happens that essential information like the content is being replaced by the dummy content I have in my local.


pipelines:
branches:
main:
- step:
name: Deploy to production
deployment: production
script:
- pipe: atlassian/rsync-deploy:0.8.1
variables:
USER: $USER
SERVER: $SERVER
REMOTE_PATH: $REMOTE_PATH
LOCAL_PATH: "${BITBUCKET_CLONE_DIR}/"
EXCLUDES: ".gitignore"



Also I realised the obvious that if I include the content folders in my .gitignore, I would remove them totally from my server. Which is not intended?

Is there a way to the pipeline ignore updating specific folders, as i want to keep them untouched on my server? The content folder on my root, for example.

This, of course, respecting what I have in my .gitignore

Thanks

2 answers

1 accepted

0 votes
Answer accepted
Hariharan Iyer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2024

Hi @Marcos Almeida ,

 

You can use the EXTRA_ARGS parameter to pass in the "filter" and/or "exclude" parameter to rsync. For example

script:
  - pipe: atlassian/rsync-deploy:0.12.0
    variables:
      USER: 'ec2-user'
      SERVER: '127.0.0.1'
      REMOTE_PATH: '/var/www/build/'
      LOCAL_PATH: 'build'
      DEBUG: 'true'
      EXTRA_ARGS:
        - "--filter=P assets/css" # double quotes here are necessary
        - "--exclude=*.txt"

Hope that helps! 

Hariharan Iyer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2024

Also, if you want the contents of .gitignore to be ignored, you will have to use 

--exclude-from=.gitignore

in the EXTRA_ARGS section.

0 votes
Marcos Almeida March 5, 2024

Hey @Hariharan Iyer 

Thanks a lot for the fast answer.

It drives me to another question: Filter or exclude flags would drive me to the same, not touching my folders on the server?

Would it look like this?

EXTRA_ARGS:
        - "--filter=P content" 
--exclude-from=.gitignore

 

Hariharan Iyer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 5, 2024

Yes, using excludes (or exclude-from) in rsync implies that files which match those patterns will not be sync'ed, so the versions on your server should not be affected. You can learn more about how/when to use the various options here - https://manpages.ubuntu.com/manpages/trusty/en/man1/rsync.1.html#filter%20rules

Marcos Almeida March 5, 2024

Perfect! Thanks a lot!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events