Skip to content

Instantly share code, notes, and snippets.

@soft2help
Created July 27, 2021 09:07
Show Gist options
  • Select an option

  • Save soft2help/b2a4a6c96cb0016e26113cdb48e4194f to your computer and use it in GitHub Desktop.

Select an option

Save soft2help/b2a4a6c96cb0016e26113cdb48e4194f to your computer and use it in GitHub Desktop.
Powershell script to bring or refresh project from remote to local
#refresh project folder to help your ide for example from remote ssh access server,
#you should have 7zip tool to windows and also your certificate to ssh server access
#check how get certificate https://gist.github.com/soft2help/1a037fc08ade3be87418ce50a0383063
#you should place in folder that will containt project folder in your localproject
#Usually i put it inside the folder .vscode folder and call it from a shortcut that i have in my powershell modules check https://github.com/soft2help/powershell-profile
#of course that you can use this script to update local from remote any folder that you want, this is an example with vendor
#PAY ATTENTION BECAUSE IN FIRST LINE OF SCRIPT REMOVE EVERYTHING EXCEPTS THE .vscode FOLDER, before download it from the remote
Get-ChildItem -Path '*' -Recurse | Where-Object {($_.FullName -notlike "*.vscode*")} | Remove-Item -Recurse -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force project.tar.gz -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force project.tar -ErrorAction SilentlyContinue
ssh -i relative_or_fullpath_to_your_certificate\id_rsa user@host "cd /var/www/html && sudo tar -cvzf project.tar.gz ."
scp -i relative_or_fullpath_to_your_certificate\id_rsa user@host:/var/www/html/project.tar.gz .
ssh -i relative_or_fullpath_to_your_certificate\id_rsa user@host "cd /var/www/html && sudo rm -rf project.tar.gz"
& 'C:\Program Files\7-Zip\7z.exe' x .\project.tar.gz
& 'C:\Program Files\7-Zip\7z.exe' x .\project.tar
Remove-Item -Recurse -Force project.tar.gz -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force project.tar -ErrorAction SilentlyContinue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment