Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # setup locations
- $ramdrive = /Volumes/ramspace
- $project = $HOME/code/someproject
- # ..create ram drive..
- # sync project directory to RAM drive
- rsync -av $project $ramdrive
- # build
- cd $ramdrive
- make
- #optional, copy the built data to the project directory:
- rsync $ramdrive/build $project/build
- # may need some error checking for bad input.
- #convert relative path to absolute
- # /bin/pwd gets real path without symbolic link on my system and pwd
- # keeps symbolic link. may need to change to suit your needs
- somedir=`cd $1; /bin/pwd`;
- somedirparent=`dirname $somedir`
- # backup directory
- /bin/tar cf $somedir.tar $somedir
- # copy, tried move like https://wiki.archlinux.org/index.php/Ramdisk
- # suggests, but got error
- mkdir -p /mnt/ramdisk$somedir
- /bin/cp -r $somedir /mnt/ramdisk$somedirparent
- # remove dir
- /bin/rm -r $somedir
- # create symbolic link. needs to be in parent of given foler.
- /bin/ln -s /mnt/ramdisk$somedir $somedirparent
- #run updater
- ~/bin/rdbackupd "/bin/tar -uf $somedir.tar $somedir" &
- #!/bin/bash
- #convert relative path to absolute
- #somepath would probably make more sense
- # pwd and not /bin/pwd so we get symbolic path
- somedir=`cd $1; pwd`;
- # remove symbolic link
- rm $somedir
- # copy dir back
- /bin/cp -r /mnt/ramdisk$somedir $somedir
- #remove from ramdisk
- /bin/rm -r /mnt/ramdisk$somedir
- #stop
- killall rdbackupd
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <signal.h>
- #include <sys/time.h>
- struct itimerval it;
- char* command;
- void update_archive(int sig)
- {
- system(command);
- }
- int main(int argc, char**argv)
- {
- it.it_value.tv_sec = 1; // start right now
- it.it_value.tv_usec = 0;
- it.it_interval.tv_sec = 60; // run every 60 seconds
- it.it_interval.tv_usec = 0;
- if (argc < 2)
- {
- printf("rdbackupd: Need command to runn");
- return 1;
- }
- command = argv[1];
- signal(SIGALRM, update_archive);
- setitimer(ITIMER_REAL, &it, NULL); // start
- while(true);
- return 0;
- }
Add Comment
Please, Sign In to add comment