-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_venv.sh
More file actions
134 lines (118 loc) · 3.64 KB
/
install_venv.sh
File metadata and controls
134 lines (118 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# Smart Backup Tool Installation Script with Virtual Environment
set -e
echo "📦 Smart Backup Tool Installation"
echo "================================="
# Check if Python 3 is installed
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is required but not installed."
echo "Please install Python 3 and try again."
exit 1
fi
# Check if pip is installed
if ! command -v pip3 &> /dev/null; then
echo "❌ pip3 is required but not installed."
echo "Please install pip3 and try again."
exit 1
fi
# Create and activate virtual environment
echo "🐍 Creating Python virtual environment..."
python3 -m venv venv
# Activate virtual environment
echo "⚡ Activating virtual environment..."
source venv/bin/activate
# Upgrade pip
echo "⬆️ Upgrading pip..."
pip install --upgrade pip
# Install Python dependencies
echo "📦 Installing Python dependencies..."
pip install -r requirements.txt
# Make scripts executable
chmod +x smart_backup.py
chmod +x run.sh
# Create config directory
CONFIG_DIR="$HOME/.config/smart-backup"
DATA_DIR="$HOME/.local/share/smart-backup"
LOGS_DIR="$DATA_DIR/logs"
mkdir -p "$CONFIG_DIR"
mkdir -p "$DATA_DIR"
mkdir -p "$LOGS_DIR"
# Create default config if it doesn't exist
CONFIG_FILE="$CONFIG_DIR/config.json"
if [ ! -f "$CONFIG_FILE" ]; then
echo "⚙️ Creating default configuration..."
cat > "$CONFIG_FILE" << EOF
{
"default_compression": true,
"compression_level": 6,
"default_encryption": false,
"backup_retention": 30,
"progress_bar": true,
"colored_output": true,
"default_exclude": [
"*.tmp",
"*.log",
"__pycache__",
"node_modules",
".git",
"*.pyc",
".DS_Store",
"Thumbs.db"
],
"compression_algorithms": {
"text": "lzma",
"images": "zip",
"videos": "none",
"archives": "none"
},
"max_threads": 4,
"chunk_size": "1MB"
}
EOF
fi
# Create alias for easy access
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ALIAS_COMMAND="alias smart-backup='$SCRIPT_DIR/run.sh'"
# Add alias to shell configuration files
for shell_config in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.bash_profile"; do
if [ -f "$shell_config" ]; then
# Check if alias already exists
if ! grep -q "alias smart-backup=" "$shell_config"; then
echo "" >> "$shell_config"
echo "# Smart Backup Tool alias" >> "$shell_config"
echo "$ALIAS_COMMAND" >> "$shell_config"
echo "Alias added to $shell_config"
else
echo "Alias already exists in $shell_config"
fi
fi
done
echo ""
echo "🎉 Installation completed successfully!"
echo ""
echo "USAGE OPTIONS:"
echo ""
echo "Option 1 - Use alias (recommended, restart terminal or run 'source ~/.bashrc'):"
echo " smart-backup --help"
echo " smart-backup create /source --destination /backup"
echo " smart-backup list --show-sizes"
echo " smart-backup restore /backup/snapshot --target /restore/path"
echo ""
echo "Option 2 - Use runner script directly:"
echo " ./run.sh --help"
echo " ./run.sh create /source --destination /backup"
echo ""
echo "Option 3 - Manual virtual environment:"
echo " source venv/bin/activate"
echo " python3 smart_backup.py --help"
echo " deactivate"
echo ""
echo "NEXT STEPS:"
echo "1. Restart your terminal or run: source ~/.bashrc"
echo "2. Test installation: smart-backup --help"
echo "3. Create your first backup: smart-backup create /source --destination /backup"
echo ""
echo "📁 Configuration: $CONFIG_DIR/config.json"
echo "📊 Logs: $LOGS_DIR"
echo ""
echo "🛡️ Never lose your data again with Smart Backup Tool!"