#!/bin/bash # this script makes an educated (hacky) guess at the archive paths that correspond to # a depot path. # # there's no logic as to whether a file is a binary or text file, so it does a # 'brute force' transfer of both. # # additionally, it spits out a list of shelved files that you can delete. # # the idea is that if you want to build a full replica of another Perforce server, # this script will help you do it in the cleanest way possible, without having to rsync # any 'cruft' that's needlessly taking up space on your server. # # script assumes Unix-like server, because reasons! path=$1 if ! [ $path ]; then echo "Please pass in a depot path [//depot/...]" fi echo echo "Finding archive file paths. Please be patient ..." # let's figure out where the depot is stored locally p4root=`p4 info |grep "^Server root" | awk '{ print $3 }'` depot=`echo $1 | sed 's#^\/\/\([^/]*\)\/.*$#\1#'` # get list of all archive paths, including lazy copies. # schmooze them into binary type depot paths as we go. p4 fstat -Oc -T depotFile,lbrFile $1 | awk '{ print $3 }' | sort -u | sed 's#^\/\(.*\)#"\'$p4root'\1,d\/"#' > transferme_bin.txt # change the binary paths to text type paths sed -e 's#,d/"$#,v"#' transferme_bin.txt > transferme_txt.txt # instructions echo echo "You can now transfer the two files 'transferme_bin.txt' and 'transferme_txt.txt' to your clean" echo "replica server and use them as a source for rsync, thusly:" echo echo "rsync -avz --progress --files-from=transferme_bin.txt [P4USER]@[P4TARGET]:/ /" echo "rsync -avz --progress --files-from=transferme_txt.txt [P4USER]@[P4TARGET]:/ /" echo echo "You could then run the list_shelved_files.sh script to get a list of shelved files and" echo "delete them. Your call ..." echo echo "It's probably not a terrible idea to run 'p4 verify -qzt' on $1, just to be sure" echo "nothing was missed." echo
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 20108 | mattyj2001 |
Whoops. Messed up the workspace mapping. You'd think after nearly 15 years of this I'd remember ... |
||
//guest/mattyj2001/guest/mattyj2001/fun_scripts/find_archives.sh | |||||
#1 | 20105 | mattyj2001 | Script to find library/archive files given a depot path. |