Handling of USB flash drive Sync.
-
I'm looking to change the option where the Retropie Synchronizes Roms and directories for file transfer when you plug in a Flash USB device, to having a similar backup of ONLY Save states and Save games when a USB device is plugged in so I an use a smaller device.
My question is where in the Pi is the file that handles the automation of mounting/syncing the USB drive, and does anybody have any suggestions for how to tweak it so that, in essence, I can wipe the device of all save data and save states, and then every time a USB device is connected, the pi will use "rsync" or similar to synchronize the save data so that only the latest information is copied over?
I tried looking into several other posts, but either I'm looking in the wrong area, or I'm not understanding how a retro pie syncs data to the USB device based on their answers.
-
You can just use the usb stick for the roms. No need to install them to the Sd card. Add a folder called retrpie-mount To the root of the usb drive. Plug it into the pi and the pi will create the roms and bios folders. Place the appropriate files in the correct folders and your all good to go. If you ever have to reformat or redo your retropie. All your games and saves will be on the usb drive.
-
@sixspeeddeath The usbromservice installed by the RetroPie scripts are in
/etc/usbmount/mount.d/
.
You can also look at them online at https://github.com/RetroPie/RetroPie-Setup/tree/master/scriptmodules/supplementary/usbromservice.Note that if you choose to modify them, they might be overwritten on a subsequent update of the RetroPie-Setup.
-
So, after some learning I'm trying to tackle this project, and I was editing the usbromservice file.
Which file controls how the files are written TO USB when you create the folder 'retropie-mount' on the USB device.
My goal is to have the USB act as a Memory card rather than a rom importing device.
in 01_retropie_copyromss, I had added --exclude '*.sfc' (as an example) with the rest of the rom extensions, leaving out the *.mpk, *.sav .state .srm files to the rom copying file after the initial --exclude '._' command hoping it would ignore all the roms in the folder, but it doesn't appear to use the same file '01_retropie_copyroms' file.
confirming the obvious enabling of USBRomservices , backing up and replacing the default 01_retropie_copyroms with my custom one, rebooting stuff (because it gets forgotten so often :p )
-
@sixspeeddeath If your goal is to use the usb as storage device, then just disable/remove the usbromservice and take a look at https://retropie.org.uk/docs/Running-ROMs-from-a-USB-drive/. There's no need to use the usbromservice in this case.
-
@mitu The end goal is to flash a pre-made image to the SD card, and periodically backup the save files to the USB.
If I fry an SD card, I just slap a newly flashed one into the pie, and plug in the USB flash drive to restore save data.
I just don't want to back up a 256mb SD card to USB with all the files, I'd just like to keep save data On USB, and the backup image on my computer :p
(That, and I'm using the retropie as a Linux learning tool, so I wanted to create unique challenges for myself)
-
@mitu Hopefully I can just use one of the plethora of 1GB flash drives I have around too, lol
-
Bump? Still looking for any way to modify the USB Sync script to only sync saves. I ended up trying to modify the 01_retropie_copyroms file, but it hangs up on my script.
What I did was add --exclude '*.xxx" for all the rom files on the ROM/BIOS sync line, and swap the source and destination in the rsync command so it now reads the USB path first, and retropie second. Finally, I tried removing the usermod line, since I'm syncing the filed FROM the pi to USB.
The script still automounts the USB, and created the file structure (rsync maxdepth=1) but it fails to fill the directory with the save games.
Still new to scripting (This device is a learning tool) What have I missed?
#!/bin/bash
This file is part of The RetroPie Project
The RetroPie Project is the legal property of its developers, whose names are
too numerous to list here. Please refer to the COPYRIGHT.md file distributed >with this source.
See the LICENSE.md file at the top-level directory of this distribution and
at https://raw.githubusercontent.com/RetroPie/RetroPie->Setup/master/LICENSE.md
config / defaults
user="pi"
home="$(eval echo ~$user)"
rootdir="/opt/retropie"
retropie_path="$home/RetroPie"usb_path="$UM_MOUNTPOINT/retropie"
usb_path_from_rp="$usb_path/configs/from_retropie"
usb_path_to_rp="$usb_path/configs/to_retropie"declare -A path_mapping
mapping from usb_path_to_rp/* to retropie location
path_mapping["configs"]="$rootdir/configs"
internals
hook_name=${0##*/}
functions
function log() {
logger -p user.$1 -t usbmount-"$hook_name"-[$$] -- "$2"
}function log_cmd() {
local ret
local error
error="$("$@" 2>&1 >/dev/null)"
ret=$?
[[ "$ret" -ne 0 ]] && log err "$* - returned $ret - $error"
}some sanity checking
if [[ -z "$UM_MOUNTPOINT" ]]; then
log err "UM_MOUNTPOINT not set!"
exit 0
fiif [[ ! -d "$UM_MOUNTPOINT" ]]; then
log err "UM_MOUNTPOINT is not a directory"
exit 0
fimake sure we have something to sync from
if [[ ! -d "$usb_path" ]]; then
exit 0
fimake folders for syncing
mkdir -p "$usb_path/"{roms,BIOS} "$usb_path_from_rp" "$usb_path_to_rp"
mirror romdir structure to external drive
log info "Attempting to create directory structure for ROMS in '$usb_path/roms' >..."
fetch list of romdirs from current installation and mirror onto external drive
find "$retropie_path/roms" -mindepth 1 -maxdepth 1 -type d -printf >"$usb_path/roms/%f\n" | xargs mkdir -p 2>/dev/null || true
copy SAVES ONLY from Local SD card stick to USB
for dir in roms BIOS; do
log info "Syncing $dir ..."
log_cmd rsync -au --exclude '._' --exclude '.32x' --exclude '.bin' --exclude >'.cue' --exclude '.gb' --exclude '.gba' --exclude '.gbc' --exclude '.gen' -->exclude '.gg' --exclude '.md' --exclude '.ndd' --exclude '.nes' --exclude '.pce' >--exclude '.sfc' --exclude '.smc' --exclude '.sms' --exclude '.vb' --exclude >'.z64' --exclude '*.zip' --max-delete=-1 "$retropie_path/" "$usb_path/$dir"
chown -R $user:$user "$retropie_path/$dir"
donelog info "Syncing configs ..."
copy configs to usb
for to in "${!path_mapping[@]}"; do
from=${path_mapping[$to]}
log_cmd rsync -au --exclude '._*' --max-delete=-1 "$from/" >"$usb_path_from_rp/$to/"
donecopy configs from usb
for from in $(find "$usb_path_to_rp/" -mindepth 1 -maxdepth 1); do
basename
from_bn=${from##/}
to=${path_mapping[$from_bn]}
if [[ -n "$to" ]]; then
log_cmd rsync -au --exclude '._' --max-delete=-1 "$from/" "$to/"
chown -R $user:$user "$to"
fi
doneunmount USB stick
umount "$UM_MOUNTPOINT"
I don't use forums either apparently, because I can't find a way to use that nifty box that allows me to add code. the --exclude DOES have a *.xxx, but it doesn't show up.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.