From 83150289e6b4d22c3e55914ab16cc11520ad84dd Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 20 Apr 2022 23:53:53 -0400 Subject: [PATCH] curl a onedrive file and notes on how to do pg_restore --- curl.md | 33 +++++++++++++++++++++++++++++++++ pg_restore.md | 9 +++++++++ 2 files changed, 42 insertions(+) create mode 100644 curl.md create mode 100644 pg_restore.md diff --git a/curl.md b/curl.md new file mode 100644 index 0000000..f5b6b7d --- /dev/null +++ b/curl.md @@ -0,0 +1,33 @@ +to curl a file from onedrive or sharepoint +------------------------------------------------------------------------------ +https://askubuntu.com/questions/1205418/wget-or-curl-gives-403forbidden-while-downloading-file-from-onedrive-for-busine + +need to first create access to the via link that anyone can use that has it + +Google Chrome as well as Mozilla Firerfox both provide an option to copy download link specifically for cURL. This option will generate cURL with all required things such as User agent for downloading things from the side. To get that, + +1. Open the URL in either of the browser. +2. Open Developer options using Ctrl+Shift+I. +3. Go to Network tab. +4. Now click on download. Saving file isn't required. We only need the network activity while browser requests the file from the server. +5. A new entry will appear which would look like "download.aspx?...". +6. Right click on that and Copy → Copy as cURL. +7. Paste the copied content directly in the terminal and append --output file.extension to save the content in file.extension since terminal isn't capable of showing binary data. + +An example of the command: +``` +curl 'https://company-my.sharepoint.com/personal/path/_layouts/15/download.aspx?SourceUrl= +%2Fpersonal%2Fsome%5Fpath%5Fin%2Ffile' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux +x86_64; rv:73.0) Gecko/20100101 Firefox/73.0' -H 'Accept: text/html,application/xhtml+xml, +application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' +--compressed -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Referer: https://company-my +.sharepoint.com/personal/path/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fagain%5Fa%5Fpath%2F +file&parent=%2Fpersonal%2Fpath%5Fagain%5Fin%2&originalPath=somegibberishpath' -H +'Cookie: MicrosoftApplicationsTelemetryDeviceId=someid; +MicrosoftApplicationsTelemetryFirstLaunchTime=somevalue; +rtFa=rootFederationAuthenticationCookie; FedAuth=againACookie; CCSInfo=gibberishText; +FeatureOverrides_enableFeatures=; FeatureOverrides_disableFeatures=' -H +'Upgrade-Insecure-Requests: 1' -H 'If-None-Match: "{some value},2"' -H 'TE: Trailers' +--output file.extension +``` + diff --git a/pg_restore.md b/pg_restore.md new file mode 100644 index 0000000..68ed8f6 --- /dev/null +++ b/pg_restore.md @@ -0,0 +1,9 @@ +pg_restore has 2 modes. if you just feed it a backup file it produces sql that you woudl have to pipe to psql or a file to run. +If you specify -d it will actually connect and execute the restore commands. + +-C combined with -c will drop and create a new database to restore into +-O will not assign ownership to the original owner, but whoever is connecting instead + +sample restore command: + +`pg_restore -O -C -c -U ptrowbridge -p 5433 -d ubm -h localhost ubm.backup`