Create new script to run this python script from anywhere, and a setup script to add it to path.
This commit is contained in:
@@ -4,6 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Commands
|
||||
- Run the backup script: `python3 backup.py`
|
||||
- Install for system-wide access: `./setup.sh`
|
||||
- No formal testing framework is used
|
||||
|
||||
## Code Style Guidelines
|
||||
@@ -18,6 +19,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
## Project Structure
|
||||
- `/configs/`: JSON configuration files for different backup jobs
|
||||
- `backup.py`: Main script for creating tar.gz or zip archives of specified directories
|
||||
- `backup`: Shell script wrapper to run backup.py from any directory
|
||||
- `setup.sh`: Installation script to make the backup command available system-wide
|
||||
|
||||
## Config File Format
|
||||
```json
|
||||
|
||||
26
README.md
26
README.md
@@ -10,6 +10,26 @@ Simple-Backup provides:
|
||||
- Pattern-based file exclusion
|
||||
- Cross-platform compatibility on Linux systems
|
||||
|
||||
## Installation
|
||||
|
||||
You can install Simple-Backup system-wide to run it from anywhere:
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/yourusername/simple-backup.git
|
||||
cd simple-backup
|
||||
|
||||
# Run the setup script
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
The setup script will either:
|
||||
1. Create a symlink in `/usr/local/bin` if you have write permissions
|
||||
2. Prompt you to run with sudo if needed
|
||||
3. Offer to add the directory to your PATH in ~/.bashrc
|
||||
|
||||
After installation, you can run the `backup` command from any directory.
|
||||
|
||||
## Configuration
|
||||
|
||||
Create new backup jobs by adding JSON configuration files to the `configs/` directory. Each configuration file should include:
|
||||
@@ -45,10 +65,10 @@ You can run backups manually or as a scheduled task:
|
||||
### Manual Execution
|
||||
|
||||
```bash
|
||||
# Make the script executable if needed
|
||||
chmod +x backup.py
|
||||
# Once installed, simply run:
|
||||
backup
|
||||
|
||||
# Run the backup
|
||||
# Or from the repository directory:
|
||||
./backup.py
|
||||
```
|
||||
|
||||
|
||||
2
backup
Executable file
2
backup
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
cd "$(dirname "$(realpath "$0")")" && python3 backup.py
|
||||
27
setup.sh
Executable file
27
setup.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create executable backup script
|
||||
chmod +x backup.py
|
||||
chmod +x backup
|
||||
|
||||
# Create a symlink in /usr/local/bin to make it accessible from anywhere
|
||||
if [ -w /usr/local/bin ]; then
|
||||
# If we have write permission to /usr/local/bin
|
||||
ln -sf "$(realpath backup)" /usr/local/bin/backup
|
||||
echo "Created symlink in /usr/local/bin/backup"
|
||||
else
|
||||
# If we don't have permission, suggest using sudo
|
||||
echo "To install system-wide, run:"
|
||||
echo "sudo ln -sf $(realpath backup) /usr/local/bin/backup"
|
||||
|
||||
# Offer to add to user's path as an alternative
|
||||
read -p "Would you like to add it to your PATH in ~/.bashrc instead? (y/n) " choice
|
||||
if [[ $choice == "y" || $choice == "Y" ]]; then
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
echo "export PATH=\"\$PATH:$SCRIPT_DIR\"" >> ~/.bashrc
|
||||
echo "Added to PATH in ~/.bashrc"
|
||||
echo "Run 'source ~/.bashrc' to apply changes"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Setup complete. You can now run 'backup' from anywhere."
|
||||
Reference in New Issue
Block a user