Skip to content

Instantly share code, notes, and snippets.

@marciomaciel
marciomaciel / rsync-media.sh
Created February 7, 2024 14:25
Shell script to sync Magento 2 / Adobe Commerce media directory
#!/bin/bash
# Function to display help message
display_help() {
echo "Usage: $0 [-s SOURCE_DIRECTORY] [-d DESTINATION_DIRECTORY]"
echo "Syncs files from source directory to destination directory based on predefined exclusions."
echo ""
echo "Options:"
echo " -s, --source SOURCE_DIRECTORY Specifies the source directory"
echo " -d, --destination DEST_DIRECTORY Specifies the destination directory"
@marciomaciel
marciomaciel / backup-media.sh
Created February 7, 2024 14:23
Script to backup Magento 2 / Adobe Commerce media directory
#!/bin/bash
# Function to display help message
display_help() {
echo "Usage: $0 [-d SOURCE_DIRECTORY]"
echo "Creates a tar.gz file based on the specified source directory and predefined exclusions."
echo ""
echo "Options:"
echo " -d, --directory SOURCE_DIRECTORY Specifies the source directory"
echo " -h, --help Display this help message"
@marciomaciel
marciomaciel / cloneGitRepo.sh
Created July 13, 2023 14:39
Clone entire GIT repository
#!/bin/bash
origRepoUrl=git@github.com:foo/bar.git
destRepoUrl=git@github.com:new-foo/new-bar.git
git clone --mirror $origRepoUrl
cd $origRepoUrl
git remote add new-origin $destRepoUrl
git push new-origin --mirror
@marciomaciel
marciomaciel / export-media.sh
Last active July 13, 2023 14:32
Export Magento Media without cache
#!/bin/bash
tar -cvf \
~/media-`date +%Y%m%d`.tar \ # Backup filename, create on ~/ for secutiry reasons
--exclude-vcs \ # Exclude any possible vcs files
--exclude='*/cache/*' --exclude='*/cache' \ # Exclude cache files
--exclude='*/.thumbs/*' --exclude='*/.thumbs' \ # Exclude thumbnail files
--exclude='*/tmp/*' --exclude='*/tmp' \ # Exclude tmp files
--exclude='*/js/*' --exclude='*/js' \ # Exclude js generated files
--exclude='*/css/*' --exclude='*/css' \ #Exclude css generated files