Underoos
Underoos

Reputation: 5190

How to download files which are created in last 24 hours using gsutil in GCP console?

I have a directory in a gcp storage bucket. And there are 2 subdirectories in that bucket.

Is there a way to download files which are created in last 24 hours in those subdirectories using gsutil command from console?

Upvotes: 0

Views: 689

Answers (2)

Underoos
Underoos

Reputation: 5190

I was able to achieve part of it using gcp console and shell.

Steps:

  1. Go to storage directory in browser gcp console.
  2. Click on filter and you'll get options to filter based on created before, created after etc.
  3. Provide the date and apply filter
  4. Click on Download button
  5. Copy the command, Open the gcp shell and run it. The required files will be downloaded there.
  6. Run the zip command in shell and archive the downloaded files.
  7. Select the Download from shell options and provide file path to download.

Upvotes: 0

John Hanley
John Hanley

Reputation: 81424

gsutil does not support filtering by date.

An option is to create a list of files to download via another tool or script, one object name per line.

Use stdin to specify a list of files or objects to copy. You can use gsutil in a pipeline to upload or download objects as generated by a program. For example:

cat filelist | gsutil -m cp -I gs://my-bucket

or:

cat filelist | gsutil -m cp -I ./download_dir

where the output of cat filelist is a one-per-line list of files, cloud URLs, and wildcards of files and cloud URLs.

Upvotes: 2

Related Questions