Created
July 19, 2022 00:28
-
-
Save fiveNinePlusR/e61726c5d66de6e7504fbdf19128df39 to your computer and use it in GitHub Desktop.
quick script to backup the current folder using ruby with a blacklist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
directory = Dir.getwd.split("/").pop | |
command = "tar czf ../#{directory}-#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.tar.gz ." | |
blacklist = %W[usr Users #{ENV["USER"]} projects] | |
blacklist << nil | |
if blacklist.include? directory | |
puts "Forbidden directory" | |
puts "Command if you want to run it manually: #{command}" | |
else | |
puts "Running: #{command}" | |
`#{command}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment