Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added allBackups/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions allBackups/backup_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

source_folder="./"
backup_folder="./allBackups"


if [ -d "$source_folder" ]; then
mkdir -p "$backup_folder"

rsync -av "$source_folder/" "$backup_folder/"

if [ $? -eq 0 ]; then
echo "Backup completed successfully."
else
echo "Backup failed. Please check the source and destination paths."
fi
else
echo "Source folder not found: $source_folder"
fi
Empty file added allBackups/hello.txt
Empty file.
32 changes: 32 additions & 0 deletions allBackups/mkc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

init() {
echo "initialised"
}
add() {
echo "added"
}
cin(){
echo "Checked in"
}
cout(){
echo "Checked Out"
}
log(){
echo "print log"
}

if [[ $1 =~ ^[0-9]+$ ]]; then
echo "invalid argument"
exit 1
elif [ $1 == "init" ]; then
init
elif [ $1 == "add" ]; then
add
elif [ $1 == "cin" ]; then
cin
elif [ $1 == "cout" ]; then
cout
elif [ $1 == "log" ]; then
log
fi
Binary file added allBackups/user/.DS_Store
Binary file not shown.
Empty file added allBackups/user/hello.txt
Empty file.
Empty file added allBackups/user/xyz.txt
Empty file.
41 changes: 41 additions & 0 deletions allBackups/versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

print_menu () {
folderPath=$1
versionSelected=$2
ogPath=$3
echo "Select an operation:"
echo "[1] Read a Version"
echo "[2] Rollback a Version"

read -p "Enter your choice: " choice

if [ "$choice" == "1" ]; then
echo "You selected 'Read a Version'."
cat "${folderPath}/${versionSelected}"
print_menu folderPath versionSelected
elif [ "$choice" == "2" ]; then
echo "You selected 'Rollback a Version'."
else
echo "Invalid choice. Please enter 1 or 2."
fi
}

root_function () {
fileName="$1"
folderName="$2"
versionsPath="./versions/${fileName}_versions"
file_path="$folderName$fileName"

if [ -e "$file_path" ]; then
echo "File Found, Select an Operation:"
echo "Versions Available:"
ls "$versionsPath"
read -p "Enter complete name of the version", versionSelected
print_menu $versionsPath $versionSelected $file_path
else
echo "File does not exist"
fi
}
root_function

Binary file added allBackups/versions/.DS_Store
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions allBackups/versions/hello.txt_versions/hello_v1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Testing content
Testing contentTesting content
Testing content
Testing content
Testing contentTesting content
1 change: 0 additions & 1 deletion allUsers.txt

This file was deleted.

19 changes: 19 additions & 0 deletions backup_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

source_folder="./"
backup_folder="./allBackups"


if [ -d "$source_folder" ]; then
mkdir -p "$backup_folder"

rsync -av "$source_folder/" "$backup_folder/"

if [ $? -eq 0 ]; then
echo "Backup completed successfully."
else
echo "Backup failed. Please check the source and destination paths."
fi
else
echo "Source folder not found: $source_folder"
fi
Loading