LAB 18 ::‐ Object Storage ‐ API Connectivity & Compute ? - guptasanjeev-52/oci_docs GitHub Wiki
Converting files in ZIP File...
Oracle cloud Infrastructure (OCI) allows us to upload files to an OBJECT STORAGE BUCKET Using either the OCI console or the** Command line Interface (CLI)** When transferring files from a Linux compute Instance , it is usually better to compress them before uploading. compression reduces the file size , which helps save object storage space and lowers storage costs. Although compression takes some CPU time , it is beneficial for long term Storage.
Archive vs Compression
People often think archiving and compression are the same, but they perform different tasks. tar (Tape Archive) The tar command combines multiple files and folders into a single archive file...
Important points::- 1.) It does not reduce the file size. 2.) It keeps the original folder structure. 3.) It preserves file permissions and metadata. 4.) It is mainly used to package multiple files together.
gzip and bzip2 Unlike tar, gzip and bzip2 are compression tools.
Their purpose is to::-
1.) Reduce file size. 2.) Compress one archive or file. 3.) Save storage space. 4.) They do not create archives by themselves, so they are commonly used together with tar.
How tar Works Creating a normal archive::-
tar -cvf backup.tar source_folder
This command only creates a single archive file. If compression is required, tar can send the archive to a compression program. For example::- -z → use gzip -j → use bzip2
Compression Methods
Using gzip (-z)
gzip is a fast compression method.
Advantages: Compresses files quickly // Uses less CPU // Best for daily backups // Produces slightly larger compressed files compared to bzip2.
Common extensions::-
.tar.gz
.tgz
Create a gzip archive.
tar -czvf destination-file_20260725.tar.gz source
Extract a gzip archive
tar -xzvf source-file_20260725.tar.gz
Using bzip2 (-j)
bzip2 focuses on achieving better compression. Advantages::-
Creates smaller files // Saves more storage space // Ideal for long-term storage.
Disadvantages::-
Compression is slower // Uses more CPU resources.
Common extensions::-
.tar.bz2
.tbz2
Create a bzip2 archive
tar -cjvf destination-file_20260725.tar.bz2 source
Extract a bzip2 archive
tar -xjvf source-file_20260725.tar.bz2
TAR Command Flags // Summary.
-c = Create a new archive -x = Extract an archive -z = Compress or extract using gzip -j = Compress or extract using bzip2 -v = Display progress (Verbose mode) -f = Specify the archive file name
Summary tar ::- Combines multiple files into one archive. gzip ::- Fast compression with lower CPU usage. bzip2 ::- Better compression ratio but slower processing. tar + gzip ::- Good for regular backups. tar + bzip2 ::- Better choice for long-term storage where saving space is important.
Run this command to send file to bucket
oci os object put -bn medical-bucket --file scripts31072026.tar
Download OCI cli package
Run below command to download OCI cli package
a)install Python 3 if not already installed:
sudo dnf install python3
write y to begin the installation
b)Install pip (Python package installer):
sudo dnf install python3-pip
write y to begin the installation
c)Install OCI CLI using pip:
python3 -m pip install oci-cli --upgrade
The OCI cli package has been successfully downloaded.
d)Verify the installation:
oci --version
Again Run below command to send file in bucket
oci os object put -bn Test-bucket --file scripts01012025.tar
Say no to creating through browser.
We will create through CLI.
Always enter default location to save config file
Enter user's OCID