Skip to content

Instantly share code, notes, and snippets.

@fiveNinePlusR
Created July 19, 2022 00:28
Show Gist options
  • Save fiveNinePlusR/e61726c5d66de6e7504fbdf19128df39 to your computer and use it in GitHub Desktop.
Save fiveNinePlusR/e61726c5d66de6e7504fbdf19128df39 to your computer and use it in GitHub Desktop.
quick script to backup the current folder using ruby with a blacklist
#! /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